Initial commit: MQL5 Scripts Collection (MetaTrader 5)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||

|
||||

|
||||
|
||||
## Source Files
|
||||
- `openrandomcharts.mq5`
|
||||
|
||||
---
|
||||
> Made with ❤️ for the trading community.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,76 @@
|
||||
#property script_show_inputs true
|
||||
|
||||
input ENUM_TIMEFRAMES timeFrame = PERIOD_MN1; //Timeframe
|
||||
input string tplName = "B01.tpl"; //Template
|
||||
input int ptsSpread = 50; //Spread Filter
|
||||
input int numCharts = 10; //Chart Count
|
||||
|
||||
void OnStart()
|
||||
{
|
||||
int i, j, k, symSpread, Charts[];
|
||||
long chartID;
|
||||
string symName = "", symPath[];
|
||||
|
||||
if(numCharts > SymbolsTotal(false) || numCharts <= 0)
|
||||
{
|
||||
Alert("ERROR: invalid chart count.");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayResize(Charts, numCharts);
|
||||
ZeroMemory(Charts);
|
||||
|
||||
i = 0;
|
||||
k = 0;
|
||||
while(i < numCharts)
|
||||
{
|
||||
//random index from symbol pool
|
||||
MathSrand(GetTickCount());
|
||||
Charts[i] = MathRand() % SymbolsTotal(false);
|
||||
symName = SymbolName(Charts[i], false);
|
||||
|
||||
//only tradeable instruments
|
||||
if(SymbolInfoInteger(symName, SYMBOL_TRADE_MODE) == SYMBOL_TRADE_MODE_DISABLED) continue;
|
||||
|
||||
//only forex instruments
|
||||
StringSplit(SymbolInfoString(symName, SYMBOL_PATH), '\\', symPath);
|
||||
if(symPath[0] != "Forex") continue;
|
||||
|
||||
//must show on marketwatch for processing
|
||||
if(SymbolInfoInteger(symName, SYMBOL_SELECT) == false) SymbolSelect(symName, true);
|
||||
Sleep(100);
|
||||
|
||||
//wait for refresh after selection
|
||||
j = 0; //time-out limitor
|
||||
while(SymbolInfoDouble(symName, SYMBOL_ASK) == 0)
|
||||
{
|
||||
Sleep(100);
|
||||
j++;
|
||||
if(j == 50) break;
|
||||
}
|
||||
if(j == 50) continue;
|
||||
|
||||
//unselect and try again if spread is above specified
|
||||
symSpread = SymbolInfoInteger(symName, SYMBOL_SPREAD);
|
||||
if(symSpread > ptsSpread)
|
||||
{
|
||||
SymbolSelect(symName, false);
|
||||
Sleep(100);
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
ArraySort(Charts);
|
||||
for(i = 0; i < ArraySize(Charts); i++)
|
||||
{
|
||||
//randomization may select same symbol again
|
||||
//so don't open same chart.
|
||||
if(i > 0 && Charts[i] == Charts[i-1]) continue;
|
||||
|
||||
symName = SymbolName(Charts[i], false);
|
||||
chartID = ChartOpen(symName, timeFrame);
|
||||
ChartApplyTemplate(chartID, "//Profiles//Templates//" + tplName);
|
||||
ChartSetInteger(chartID, CHART_SHIFT, 0, true);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Reference in New Issue
Block a user