Expert Advisor for multiple symbols

 

Hello,

I am developing own semi-automated trading solution with possibility to connect to MetaTrader platform.

I use C# and MtAPI (http://mtapi4.net/) - this library provide connector between Expert Advisor for MQL and C# code; data transmission (real-time, history bars, ticks) works fine.

But I encountered in an issue, that when advisor can`t send order to another symbol.

For example, advisor attached to EURUSD chart, and after sending SendOrder request for GBPUSD:

{"RequestType":3,"TradeRequest": 

{"Action":1,"Magic":1234,"Order":9081237634512,"Symbol":"GBPUSD","Volume":0.1, 

 "Price":1.2038,"Stoplimit":0.0,"Sl":0.0,"Tp":0.0,"Deviation":5,"Type":0,"Type_filling":0, "Type_time":0,"Comment":"Test Trade Request","Position":0,"PositionBy":0,"MtExpiration":0 } 

}

I receive response from MQL:

{Retcode=10021; Comment=No prices; Deal=0; Order=0; Volume=0; Price=0; Bid=0; Ask=0; Request_id=0}

If user attach advisor to Chart with GBPUSD - advisor can send orders, but it`s not convenient, user should manually attach advisor to each Chart with symbol he want to trade.

How I can avoid that "No prices" error? Somehow subscribe? or how I can open my advisor for all allowed symbols?

 
crazy.gamer:

Hello,

I am developing own semi-automated trading solution with possibility to connect to MetaTrader platform.

I use C# and MtAPI (http://mtapi4.net/) - this library provide connector between Expert Advisor for MQL and C# code; data transmission (real-time, history bars, ticks) works fine.

But I encountered in an issue, that when advisor can`t send order to another symbol.

For example, advisor attached to EURUSD chart, and after sending SendOrder request for GBPUSD:

I receive response from MQL:

If user attach advisor to Chart with GBPUSD - advisor can send orders, but it`s not convenient, user should manually attach advisor to each Chart with symbol he want to trade.

How I can avoid that "No prices" error? Somehow subscribe? or how I can open my advisor for all allowed symbols?

Have you looked into MarketInfo(mySymbol...) to get the current price etc for a non chart symbol?
Reason: