Ok I succeed placing a buy stop order. I needed expiration time...
Here is the code I used and it's working...
MqlTradeRequest request;
MqlTradeResult result;
if(m_achat && m_achat2)
{
request.action = TRADE_ACTION_PENDING;
request.type = ORDER_TYPE_BUY_STOP;
request.symbol = Symbol();
request.magic = m_magic;
request.price = m_highest;
request.volume = m_lots;
request.tp = m_highest + m_limit*m_symbol.Point();
request.sl = m_highest - m_stop*m_symbol.Point();
request.deviation = 50;
request.type_filling = ORDER_FILLING_AON;
request.expiration = TimeCurrent()+24*60*60;
request.comment = "Expert test buy stop";
ok = OrderSend(request,result);
if(!ok)
{
err = GetLastError();
Print("error buy stop (",err,")");
}
}
But, I now try to place a sell stop, and this code is not working... I get the 4756 error...
if(m_vente && m_vente2)
{
MqlTradeRequest request2;
MqlTradeResult result2;
request2.action = TRADE_ACTION_PENDING;
request2.type = ORDER_TYPE_SELL_STOP;
request2.symbol = Symbol();
request2.magic = m_magic;
request2.price = m_lowest;
request2.volume = m_lots;
request2.tp = m_lowest - m_limit*m_symbol.Point();
request2.sl = m_lowest + m_stop*m_symbol.Point();
request2.deviation = 50;
request2.type_filling = ORDER_FILLING_AON;
request2.expiration = TimeCurrent()+24*60*60;
request2.comment = "Expert test sell stop";
ok = OrderSend(request2,result2);
if(!ok)
{
err = GetLastError();
Print("error sell stop(",err,")");
}
}
Any idea?
Cam'
Ok I succeed placing a buy stop order. I needed expiration time...
Here is the code I used and it's working...
But, I now try to place a sell stop, and this code is not working... I get the 4756 error...
Any idea?
Cam'
I tried to run your code to place Sell Stop order. Order was placed successfully.
You got 4756 error in Experts tab. Were there any errors in Journal tab?
I tried to run your code to place Sell Stop order. Order was placed successfully.
You got 4756 error in Experts tab. Were there any errors in Journal tab;
Indeed I didn't paid attention to journal errors...
I got the following message : "2010.06.29 14:39:51 Trades '2809' : failed sell stop 0.10 EURUSD at 1.22650 sl: 1.22700 tp: 1.22550 [Invalid stops]"
What does "invalid stops" mean?
Thanks for your help!
Cam'
Indeed I didn't paid attention to journal errors...
I got the following message : "2010.06.29 14:39:51 Trades '2809' : failed sell stop 0.10 EURUSD at 1.22650 sl: 1.22700 tp: 1.22550 [Invalid stops]"
What does "invalid stops" mean?
Thanks for your help! It's working now!
Cam'
Thanks for your help! It's working now!
Cam'
In the future try also to analyze not only last error code, but also function retcode: in your case result2.retcode. It might be more useful.
Also you can check whether order will be placed or not with OrderCheck function. It is very useful!
- 2010.05.26
- KlimMalgin
- www.mql5.com
You try to specify Stop Loss or Take Profit too close to current price (for position) or to open price (for pending order).
I received the invalid stops message trying to open a buystop with sl and tp in 0 (without them) sometimes I get the error sometimes doesnt, is very strange, any ideas?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I don't succeed in placing a buy stop order...
When using a MqlTradeRequest and OrderSend(), what information do I need to enter??
What are stoplimit and price representing in the case of a buy stop order?
Thx,