MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Freelancer services needed to perform 150+ jobs of traders

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.

 
Active or Passive? How to Mix Aspects of Both

Active or Passive? How to Mix Aspects of Both

Investment fund strategies can generally be divided into either active or passive management. While the latter describes funds that seek to track a particular index, the former refers to funds actively managed by financial professionals who typically try to outperform a given benchmark. For most investors, deciding on whether to use active or passive funds is largely a matter of faith or moral certainty.

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