Sleep() on Loss

 
Hi all,

What I 'm trying to achieve is that I don't want the EA to enter on
the same bar that it took a lost. I can't figure it out.How would one
do to put EA on sleep() for like 10 minutes if last trade was a lost?

Help would be appreciated. Thanks.

Maxime Chartrand.
 
Hi all,

What I 'm trying to achieve is that I don't want the EA to enter on
the same bar that it took a lost. I can't figure it out.How would one
do to put EA on sleep() for like 10 minutes if last trade was a lost?

Help would be appreciated. Thanks.

Maxime Chartrand.

Check last trade in the history.
 
Hi all,

What I 'm trying to achieve is that I don't want the EA to enter on
the same bar that it took a lost. I can't figure it out.How would one
do to put EA on sleep() for like 10 minutes if last trade was a lost?

Help would be appreciated. Thanks.

Maxime Chartrand.

Check last trade in the history.


And how would I do that? Finding in history the last trade is ok, but how to see if it was a loss?

Thanks for helping.
 

And how would I do that? Finding in history the last trade is ok, but how to see if it was a loss?

Thanks for helping.


 
   for(i=HistoryTotal()-1; i>=0; i--) 
   {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
      if(OrderSymbol()!= Symbol() || OrderMagicNumber() != Magic) continue;
      if(OrderProfit() < 0) LastLossTime = MathMax(LastLossTime, OrderCloseTime());
   }
   if(CurTime() - LastLossTime < SleepAfterLoss * 60)  Sleep(SleepAfterLoss * 60 - CurTime() + LastLossTime);