Results 1 to 4 of 4
 0 Attachment(s)    

Thread: Add a time filter

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    11

    Default Add a time filter

    Help me,please.I am not a programmer.
    Thank you in advanced.
    Last edited by sunyc1982; 05-27-2010 at 06:24. Reason: Not ready.

  2. #2
    Junior Member
    Join Date
    Mar 2010
    Posts
    3

    Default

    Hi, i also need help on how to add a timefilter and dayfilter in ea. I tried it but it didnt work.
    Im searching for this filters to code them into frank_ud (normal version)

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    14

    Default

    I will try to explain how I do it.

    Declare these variables at the top:
    Code:
    extern int EndHour = 18;
    extern int StartHour = 9;
    bool StopTrading;
    Then create this method somewhere at the bottom of the EA:
    Code:
    void CheckTime()
    {
       int h=TimeHour(TimeCurrent());
       if(h>EndHour || h<StartHour)
       {
          StopTrading=true;
       }
    }
    Then in the start function put this:
    Code:
          StopTrading = false;
          CheckTime();
          
          if(StopTrading==false)
          {
             //The trading logic of the EA goes here
          }
    This is for the time filter. I hope to have helped.

    By the way, for a day filter it is the same except where it says
    Code:
    int h=TimeHour(TimeCurrent());
    change it to
    Code:
    int d=TimeDayOfWeek(DayOfWeek());
    And change all the "h" to "d" in the check time function. Also declare the variables at the top for StartDay and EndDay (They are an int ranging from 0-6 and 0 is Sunday, 1 being Monday, etc.

    Chris
    Last edited by chrisbenjy; 06-26-2010 at 19:22.

  4. #4
    Junior Member
    Join Date
    Feb 2011
    Posts
    14

    Default

    Quote Originally Posted by chrisbenjy View Post
    I will try to explain how I do it.

    Declare these variables at the top:
    Code:
    extern int EndHour = 18;
    extern int StartHour = 9;
    bool StopTrading;
    Then create this method somewhere at the bottom of the EA:
    Code:
    void CheckTime()
    {
       int h=TimeHour(TimeCurrent());
       if(h>EndHour || h<StartHour)
       {
          StopTrading=true;
       }
    }
    Then in the start function put this:
    Code:
          StopTrading = false;
          CheckTime();
          
          if(StopTrading==false)
          {
             //The trading logic of the EA goes here
          }
    This is for the time filter. I hope to have helped.

    By the way, for a day filter it is the same except where it says
    Code:
    int h=TimeHour(TimeCurrent());
    change it to
    Code:
    int d=TimeDayOfWeek(DayOfWeek());
    And change all the "h" to "d" in the check time function. Also declare the variables at the top for StartDay and EndDay (They are an int ranging from 0-6 and 0 is Sunday, 1 being Monday, etc.

    Chris
    This is true when you trade from 9 - 18 hours , but you can also wanted to trade 23 - 5 next day.
    So checktimefilter should be

    void CheckTime()
    {
    int h=TimeHour(TimeCurrent());
    if(((h>EndHour || h<StartHour) && StartHour<EndHour) ||
    ((h<EndHour || h>StartHour) && StartHour>EndHour))
    {
    StopTrading=true;
    }
    }

Similar Threads

  1. Mandor EA time filter
    By EaLabSpain in forum Ideas for expert advisors
    Replies: 0
    Last Post: 04-10-2012, 20:36
  2. Time filter
    By Viv108 in forum MQL programming
    Replies: 19
    Last Post: 05-25-2011, 12:07
  3. Time filter code
    By himnoor in forum MQL programming
    Replies: 0
    Last Post: 12-21-2010, 02:55
  4. Req. Trading Time Filter
    By Trint in forum Ideas for expert advisors
    Replies: 0
    Last Post: 01-23-2010, 09:19
  5. Add a time filter
    By funyoo in forum MQL programming
    Replies: 12
    Last Post: 05-28-2009, 22:26

Tags for this Thread

add, how to, programmer, stop, time, timefilter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •