First of all, what i'm trying to achieve is a bot which can run on multiple currency pairs. I've defined an array called symbols[] as per the line above. Then I have this...
So, upon every tick, my bot checks if the hours are withing the desired trading hours, checks if there are currently no positions open (only allowing one trade at a time) and - in this example - checks to see if the RSI is greater than 70 or below 30. If so, it places a trade.
How do I loop through the pairs listed in my Symbols[] string and reference them one at a time, in order to create a bot which works with multiple currency pairs at once? I'm going to need to change _symbol in the MinuteRSI sub routine and inside my PlaceTrade sub routine also? In fact, wherever _symbol appears, i'll do a find and replace for all cases. Just not sure how the loop works. Please educate me.
https://www.mql5.com/en/articles/234
have you read this?
- www.mql5.com
void MinuteRSI(string s) { double M_RSIArray[]; int M_RSIDefinition = iRSI(s, PERIOD_M1, RSIPeriod, PRICE_CLOSE); ArraySetAsSeries(M_RSIArray, true); CopyBuffer(M_RSIDefinition,0,0,3,M_RSIArray); M_RSIValue = NormalizeDouble(M_RSIArray[0],2); // Current M1 Bar M_RSIValueOld = NormalizeDouble(M_RSIArray[0],2); // ALL Minute RSI CODE GOES HERE!!! } void OnTick() { if(IsTradingTime()) { // This is where I would like the beginning of the loop to start for(int i = 0; i < ArraySize(symbols); i++) { if(PositionsTotal() == 0 && TradeRepeatFlag == 0) { MinuteRSI(symbols[i]); if(M_RSIValue >= 70 || M_RSIValue <= 30) { // Place a trade and manage it blah blah blah } } // This is where the } goes to close the new loop } } }
Maybe something like that?
Yes, I've read that previously. It's not so much building a bot which relies on data from other instruments for triggers as this article describes or any arbitrage purposes. I'd just like to run i.e. a simple RSI strategy on multiple instruments independently with the same bot in order to ping some alerts to me on the best opportunity, without having to attach the bot to several charts.
Ahhh, so run the for loop with i between 0 and ArraySize (didn't know that was a thing, thanks).
When i = 1, would symbols[i] = "GBPUSD" (as per the first line of my first message)??? I'll test this out for myself obviously but the reason I ask is inside MinuteRSI, you didn't use symbols[i] instead of _symbols on the second line, you used 's'. Where has this come and what's going on here please?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
First of all, what i'm trying to achieve is a bot which can run on multiple currency pairs. I've defined an array called symbols[] as per the line above. Then I have this...
So, upon every tick, my bot checks if the hours are withing the desired trading hours, checks if there are currently no positions open (only allowing one trade at a time) and - in this example - checks to see if the RSI is greater than 70 or below 30. If so, it places a trade.
How do I loop through the pairs listed in my Symbols[] string and reference them one at a time, in order to create a bot which works with multiple currency pairs at once? I'm going to need to change _symbol in the MinuteRSI sub routine and inside my PlaceTrade sub routine also? In fact, wherever _symbol appears, i'll do a find and replace for all cases. Just not sure how the loop works. Please educate me.