I have a problem when using string arrays. When I drop my EA on GBPUSD it will not open and others pairs. It only opens on the 1st arrays "EURUSD" and "USDJPY".
this looks wrong - you are assigning the 1st element every time:
string symbol=Base[0];
Try this (in both loops)
string symbol=Base[loop];
Also in the later statements you are accessing the [0] element only:
double Price=SymbolInfoDouble(Base[0],SYMBOL_ASK); double Price2=SymbolInfoDouble(Base2[0],SYMBOL_BID); double TakeProfitBuy=Price+TakeProfit*Pips(Base[0]); double StopLossBuy=Price-StopLoss*Pips(Base[0]); double TakeProfitSell=Price2-TakeProfit2*Pips(Base2[0]); double StopLossSell=Price2+StopLoss2*Pips(Base2[0]);
I have a problem when using string arrays. When I drop my EA on GBPUSD it will not open and others pairs. It only opens on the 1st arrays "EURUSD" and "USDJPY".
You can also do the SELL part.
string Base[]={"EURUSD","GBPUSD","AUDUSD","NZDUSD"}; string Base2[]={"USDJPY","USDCHF","USDCAD"}; for(int Loop=0;Loop<4;Loop++) { if(CountSymbol(Symbol())<1) { double EntryPrice=NormalizeDouble((MarketInfo(Base[Loop],MODE_ASK)+50*MarketInfo(Base[Loop],MODE_POINT)),MarketInfo(Base[Loop],MODE_DIGITS)); double EntrySL=NormalizeDouble((EntryPrice-StopLoss*MarketInfo(Base[Loop],MODE_POINT)),MarketInfo(Base[Loop],MODE_DIGITS)); double EntryTP=NormalizeDouble((EntryPrice+TakeProfit*MarketInfo(Base[Loop],MODE_POINT)),MarketInfo(Base[Loop],MODE_DIGITS)); bool BuyTrade=OrderSend(Base[Loop],OP_BUYSTOP,0.01,EntryPrice,3,EntrySL,EntryTP,"Scalper8",MagicNumber,0,clrBlue); // Print(GetLastError()," ",Base[Loop]," ",EntryPrice," ",EntrySL," ",EntryTP); } }
Glad it got sorted - I recommend using the debugger in such cases. By inspecting variables during runtime you can often identify semantic issues which are not apparent when coding/compiling.
In case it helps, here is a ref:
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a problem when using string arrays. When I drop my EA on GBPUSD it will not open and others pairs. It only opens on the 1st arrays "EURUSD" and "USDJPY".