MqlTradeRequest mqlrequest={0};
Please read the documentation, buy stop/sell stop is a pending not a deal order.
Place a trade order for the execution under specified conditions (pending order) |
If you are using true ECN broker.
Order should be loaded in two step.
step 1. Place the order with Sl=0.0 and TP=0.0.
step 2. Modify the order to set desired SL and TP.
If you are using true ECN broker.
Order should be loaded in two step.
step 1. Place the order with Sl=0.0 and TP=0.0.
step 2. Modify the order to set desired SL and TP.
Please read the documentation, buy stop/sell stop is a pending not a deal order.
Place a trade order for the execution under specified conditions (pending order) |
Please read the documentation, buy stop/sell stop is a pending not a deal order.
Place a trade order for the execution under specified conditions (pending order) |
Thanks for the reply Alain Verleyen !!
What are the parameters that we need to fill in MqlTradeRequest mqlrequest; in all below parameters to place Sell stop loss order after a buying.
I tried with below code but it is giving me invalid price.
mqlrequest={0};
mqlrequest.action = TRADE_ACTION_PENDING;
mqlrequest.price = NormalizeDouble(latest_price.bid,_Digits);
mqlrequest.sl = NormalizeDouble(latest_price.bid + STP,_Digits);
mqlrequest.tp = NormalizeDouble(latest_price.bid - TKP,_Digits);
mqlrequest.symbol = _Symbol;
mqlrequest.volume = Lot;
mqlrequest.magic = MagicNum;
mqlrequest.type= ORDER_TYPE_SELL_STOP;
mqlrequest.type_filling = ORDER_FILLING_FOK;
mqlrequest.deviation=100;
Thanks for the reply Alain Verleyen !!
What are the parameters that we need to fill in MqlTradeRequest mqlrequest; in all below parameters to place Sell stop loss order after a buying.
I tried with below code but it is giving me invalid price.
mqlrequest={0};
mqlrequest.action = TRADE_ACTION_PENDING;
mqlrequest.price = NormalizeDouble(latest_price.bid,_Digits);
mqlrequest.sl = NormalizeDouble(latest_price.bid + STP,_Digits);
mqlrequest.tp = NormalizeDouble(latest_price.bid - TKP,_Digits);
mqlrequest.symbol = _Symbol;
mqlrequest.volume = Lot;
mqlrequest.magic = MagicNum;
mqlrequest.type= ORDER_TYPE_SELL_STOP;
mqlrequest.type_filling = ORDER_FILLING_FOK;
mqlrequest.deviation=100;
Instructions given by Alain is clear.
Try to read carefully this document and example script:
https://www.mql5.com/en/docs/trading/ordersend
- 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 am trying send write buy stop and sell stop order using below code in Strategy Tester, but it is giving me below error
failed instant sell stop limit 0.01 GBPUSD at 1.42418 sl: 1.42397 tp: 1.42440 [Invalid request]
MqlTradeRequest mqlrequest;
MqlTradeResult mqlresult;
mqlrequest.action=TRADE_ACTION_DEAL;
mqlrequest.price = NormalizeDouble(result.bid,5);
mqlrequest.sl = NormalizeDouble(result.bid-0.00021,5);
mqlrequest.tp=NormalizeDouble(result.bid+0.00022,5);
mqlrequest.symbol=_Symbol;
mqlrequest.volume=Lot;
mqlrequest.magic=MagicNum;
mqlrequest.type=ORDER_TYPE_BUY_STOP;
mqlrequest.type_filling=ORDER_FILLING_FOK;
mqlrequest.deviation=Deviation;
OrderSend(mqlrequest ,mqlresult);
also please explain how to use price, sl and tp in sending buy stop and sell stop orders.
Thanks in advance!!