Buy algorithmic trading applications in MetaTrader Market. Its fast!

Get last order result (buy,sell,close,stop loss)...

Back to topics list To post a new topic, please log in or register
avatar
8
jjperellos 2007.09.04 22:27
 

Hello,

I'm working with an ea, and I need to know if the last trade closed for stop loss.

How can I know it?

Thanks.

 
GBP/USD a touch softer ahead of US data
GBP/USD a touch softer ahead of US data
Andrius Kulvinskas | 29 January 2015, 14:11 | Views: 28
 GBP/USD settled in a lower range on Thursday as the greenback strengthened a tad following the Federal Reserve statement. GBP/USD climbed to a daily high of 1.5161 during the European session, but was rejected and sent to a low of 1.5109. In the absence of first-tier data from the UK, the pair entered a consolidation phase as investors await US pending home sales, jobless weekly claims and and a series of earning reports from Wall Street.
avatar
322
wackena 2007.09.04 23:56 #
 

Try this:

Stringo provided this code to find last closed trade in another thread.

int last_trade=HistoryTotal();
if(last_trade>0)
  {
   if(OrderSelect(last_trade-1,SELECT_BY_POS,MODE_HISTORY)==true)
     {
      Print("Last trade ticket ",OrderTicket(),"   op ",OrderType(), "   time ",TimeToStr(OrderCloseTime()),"   price ",OrderClosePrice());
     }
  }

You could change to this:

int last_trade=HistoryTotal();
if(last_trade>0)
  {
   if(OrderSelect(last_trade-1,SELECT_BY_POS,MODE_HISTORY)==true)
     {
      if(OrderSymbol()==Symbol() && OrderClosePrice()==OrderStopLoss())
         {
          Print("Last closed order was OrderType = ",OrderType(),"  Time = ",TimeToStr(OrderCloseTime()),"  close at StopLoss  ",OrderClosePrice());
         }
     }
  }
you can replace OrderStopLoss() with OrderTakeProfit() for when order closes at takeprofit.

 
Back to topics list  

To add comments, please log in or register