Code for Trade hour
Results 1 to 8 of 8

Thread: Code for Trade hour

  1. #1
    Hi Peoples,

    I am attempting to receive my EA to exchange only between certain hours.
    Can anybody shed some light on why this code won't work for me?



    Extern bool UseHourTrade = True;
    extern int GMTOffSet = 1;
    extern int FromHourTrade = 6;
    extern int ToHourTrade = 18;



    if(MayOpenDeferOrder) // MayOpenDeferOrder is a buy stop or buy limit order

    if ((UseHourTrade==true) ((Hour() GMTOffSet)lt;= FromHourTrade (Hour() GMTOffSet) gt;= ToHourTrade)) MayOpenDeferOrder = false;


    Thank you Beforehand,

    A

  2. #2
    You have it backwards.

    I'm assuming you want the EA to trade between 6:00 and 18:00, correct?

    if(Hour() gt;= StartTime Hour() lt; EndTime) OrderSend...

  3. #3
    Quote Originally Posted by ;
    You have it backwards.

    I am assuming you want the EA to exchange between 6:00 and 18:00, correct?

    If(Hour() gt;= StartTime Hour() lt; EndTime) OrderSend...
    I'm a beginner (just started coding now) and what the lineup is supposed to say is;

    Assess before submit and when the time is out trade hour, don't submit this order.

    So it's not working like that. . I must be wrong. Am I still back to front?

  4. #4
    Ok,

    if(MayOpenDeferOrder) // MayOpenDeferOrder is a buy stop or buy limit order

    if ((UseHourTrade==true)
    //When time is earlier than the starting time
    ((Hour() GMTOffSet)lt;= FromHourTrade
    //When time is later than the ending time
    (Hour() GMTOffSet) gt;= ToHourTrade)) MayOpenDeferOrder = false;


    The time cannot be equally earlier than the starting time, AND later than the starting time. You Have to use the OR || command.

    So...

    if(MayOpenDeferOrder) // MayOpenDeferOrder is a buy stop or buy limit order
    (Hour() GMTOffSet) gt;= ToHourTrade)))MayOpenDeferOrder = false;

  5. #5
    You might choose to use TimeHour(TimeCurrent()); to your hour. I seem to recall something irresistible regarding Hour();

  6. #6
    Quote Originally Posted by ;
    Ok,

    if(MayOpenDeferOrder)...
    Thanks mate, still not working but I am certain that I would never have it working if I'd used the rather than the.

    Getting nearer

  7. #7
    Quote Originally Posted by ;
    You may choose to use TimeHour(TimeCurrent()); to your hour. I seem to remember something goofy about Hour();
    Okay, I'll look up that and put that in instead. .

    1.30am here. . Possibly I shall continue this tomorrow

    cheers

    A

  8. #8
    Ok, Thanks Guys,

    Exactly what I wanted and it works Today,



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information