How do I refer to a stop loss if the stop loss is achieved - page 2

 
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]

 
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.

 
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");
 
  1. 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.

  2. Iurii Tokman:
    OrderProfit() < 0

    A SL can be trailed and close an order in profit.

  3. See #2.4

 
William Roeder:
  1. A SL becomes a market order when hit. Due to slippage, it can close much greater away than point.

  2. A SL can be trailed and close an order in profit.

  3. See #2.4

what the a right code for this point 
 
if(OrderType()==OP_BUY && OrderClosePrice()<=OrderStopLoss())//Buy SL hit
if(OrderType()==OP_SELL && OrderClosePrice()>=OrderStopLoss())//Sell SL hit

I think this one should work

 
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);
 
Iurii Tokman:

Thank you :) it is run Good

 
Youssef Ibrahim Abbas Mohammed Saleh:

Thank you :) it is run Good

you are welcome

Reason: