Для функции OrderSend надо делать проверку:
void BuyPendingOrder1() { price= SymbolInfoDouble ( Symbol (), SYMBOL_ASK )+ 0.0002 ; double SL=price-StopLoss* 0.00001 ; if (StopLoss== 0 ) SL= 0 ; double TP=price+TakeProfit* 0.00001 ; if (TakeProfit== 0 ) TP= 0 ; //--- prepare the request MqlTradeRequest request; request.action= TRADE_ACTION_PENDING ; request.symbol = Symbol (); request.volume = Lots; request.sl = SL; request.tp = TP; request.deviation= 4 ; request.price=price; //--- form the order type request.type= ORDER_TYPE_BUY_STOP ; // order type ORDER_TYPE_BUY_LIMIT, ORDER_TYPE_SELL_LIMIT, ORDER_TYPE_BUY_STOP, ORDER_TYPE_SELL_STOP //--- form the price for the pending order request.type_filling= ORDER_FILLING_RETURN ; // request.type_time = ORDER_TIME_GTC; request.expiration= ORDER_TIME_GTC ; MqlTradeResult result; bool success= OrderSend (request,result); if (!success) { //check here } }
tenlau:
Hello,
I try to compose a simple EA. Below is the code.
Please answer why the Invalid request is posted in Journal
Thanks in advance!
//--- prepare the request MqlTradeRequest request={0};You have to initialize your variable (you can use ZeroMemory() also).
Thanks, your advice worked !
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I try to compose a simple EA. Below is the code.
Please answer why the Invalid request is posted in Journal
Thanks in advance!