How do I refer to a stop loss if the stop loss is achieved - page 2 12 New comment Nikolay Georgiev 2020.12.27 19:05 #11 for(int i =0;i<OrdersHistoryTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) { if(StringFind(OrderComment(),"[sl]",0)!=-1) { Print(OrderComment()," ",OrderProfit()); } } } Are you sure you just check what it added for stop loss, normally brokers add [sl] William Roeder 2020.12.27 19:15 #12 Nikolay Georgiev: You can check with OrderComment since if a stop loss has occured the "[sl]" is normally added there Broker dependent. Only some brokers do that. Iurii Tokman 2020.12.27 20:13 #13 Youssef Ibrahim Abbas Mohammed Saleh: Sorry this code work in a two type ( stop loss , take profit ) both when a stop loss happens is work good And when the take profit happens it is work also :( if you have a correct code work for stop loss only and i'm very happy because you helping me if(NormalizeDouble(MathAbs(OrderClosePrice()-OrderStopLoss()),Digits())<Point()) Alert("SL"); if(NormalizeDouble(MathAbs(OrderClosePrice()-OrderTakeProfit()),Digits())<Point()) Alert("TP"); William Roeder 2020.12.27 21:16 #14 Iurii Tokman: if(NormalizeDouble(MathAbs(OrderClosePrice()-OrderStopLoss()),Digits())<Point()) A SL becomes a market order when hit. Due to slippage, it can close much greater away than point. Iurii Tokman: OrderProfit() < 0 A SL can be trailed and close an order in profit. See #2.4 Youssef Ibrahim Abbas Mohammed Saleh 2020.12.28 08:19 #15 William Roeder: A SL becomes a market order when hit. Due to slippage, it can close much greater away than point. A SL can be trailed and close an order in profit. See #2.4 what the a right code for this point Nikolay Georgiev 2020.12.28 10:45 #16 if(OrderType()==OP_BUY && OrderClosePrice()<=OrderStopLoss())//Buy SL hit if(OrderType()==OP_SELL && OrderClosePrice()>=OrderStopLoss())//Sell SL hit I think this one should work Iurii Tokman 2020.12.28 10:54 #17 Youssef Ibrahim Abbas Mohammed Saleh: what the a right code for this point int Delta = 10; //0...9999... if(NormalizeDouble(MathAbs(OrderClosePrice()-OrderStopLoss()),Digits()) < Delta * Point()) return(true); Youssef Ibrahim Abbas Mohammed Saleh 2020.12.28 18:49 #18 Iurii Tokman: Thank you :) it is run Good Iurii Tokman 2020.12.28 18:57 #19 Youssef Ibrahim Abbas Mohammed Saleh: Thank you :) it is run Good you are welcome 12 New comment
Are you sure you just check what it added for stop loss, normally brokers add [sl]
Broker dependent. Only some brokers do that.
Sorry this code work in a two type ( stop loss , take profit ) both
when a stop loss happens is work good
And when the take profit happens it is work also :(
if you have a correct code work for stop loss only
and i'm very happy because you helping me
A SL becomes a market order when hit. Due to slippage, it can close much greater away than point.
OrderProfit() < 0A SL can be trailed and close an order in profit.
See #2.4
A SL becomes a market order when hit. Due to slippage, it can close much greater away than point.
A SL can be trailed and close an order in profit.
See #2.4
I think this one should work
what the a right code for this point
Thank you :) it is run Good
Thank you :) it is run Good
you are welcome