Download MetaTrader 5

Order Send and Traders Time

To add comments, please log in or register
MThomp
65
MThomp  

hello, if i have to link Trader's choice of Time to trade with  OrderSend in EA  using the  following
code: 

 

 

          TIME:

  bool TradeTime=false;

    if (Hour()>StartHour)&&(Hour()<EndHour))

          || (Hour()==StartHour&&Minute()>=StartMinute)
           || (Hour()==EndHour&&Minute()<EndMinute)
)
        TradeTime=true;


   [ORDERSEND].

int ms = GetTickCount ();
      tick = OrderSend (Symbol (), dir, lots, price, use_slp, use_sl, use_tp, "", magic_number) ;
      placing the following can the Traders Time be executed on EA.

 

(The trader has to select a specific time to trade.)


 Still not getting the result. Pls any suggestions 


whroeder1
15017
whroeder1  
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Check your return codes (OrderSend) and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
whroeder1
15017
whroeder1  
Memma30: Pls any suggestions
Learn to READ.
  1. Original post - not edited
  2. Duplicate post - no SRC
  3. Check return codes - suggestion ignored
Keith Watford
Moderator
9980
Keith Watford  
 if (Hour()>StartHour)&&(Hour()<EndHour))
 
 //Is the same as

 if (Hour()>StartHour)
     &&(Hour()<EndHour))

Sort out your () brackets as they are not correctly placed. Does your code even compile?

 

  if((Hour()>StartHour && Hour()<EndHour)
      || (Hour()==StartHour && Minute()>=StartMinute)
      || (Hour()==EndHour && Minute()<EndMinute))

is better. Your code does not take into account if the session period passes through midnight

To add comments, please log in or register