Can an EA run on a custom timeframe?

 

Hi folks,

Does anyone know if I can run an EA on a custom time frame?  I mean run a live EA that places real orders.

If you google it, you find plenty about using a custom time frame in Strategy Tester.  But I have not come across anything about using one live.

I have tried to attach an EA to a custom time frame and it doesn't work.  The EA does in fact attach, but it won't place orders.

This tells me that no, it can't be done.  But maybe there is some step I am missing.  Since there is so much information about testing custom time frames in Strategy Tester, it doesn't make sense to me that you can't actually trade the EA that you tested.

If anyone can shed any light it would be appreciated.

Thanks and best,

Jeff

 
Jeff Kotnik:

Hi folks,

Does anyone know if I can run an EA on a custom time frame?  I mean run a live EA that places real orders.

If you google it, you find plenty about using a custom time frame in Strategy Tester.  But I have not come across anything about using one live.

I have tried to attach an EA to a custom time frame and it doesn't work.  The EA does in fact attach, but it won't place orders.

This tells me that no, it can't be done.  But maybe there is some step I am missing.  Since there is so much information about testing custom time frames in Strategy Tester, it doesn't make sense to me that you can't actually trade the EA that you tested.

If anyone can shed any light it would be appreciated.

Thanks and best,

Jeff

Hi Jeff,

you don't mention which language you use (MQL4 or MQL5). I will assume you are talking about MQL5.

The predefined timeframes are these and they work as it is obvious both in the strategy tester and live.

ID

Description

PERIOD_CURRENT

Current timeframe

PERIOD_M1

1 minute

PERIOD_M2

2 minutes

PERIOD_M3

3 minutes

PERIOD_M4

4 minutes

PERIOD_M5

5 minutes

PERIOD_M6

6 minutes

PERIOD_M10

10 minutes

PERIOD_M12

12 minutes

PERIOD_M15

15 minutes

PERIOD_M20

20 minutes

PERIOD_M30

30 minutes

PERIOD_H1

1 hour

PERIOD_H2

2 hours

PERIOD_H3

3 hours

PERIOD_H4

4 hours

PERIOD_H6

6 hours

PERIOD_H8

8 hours

PERIOD_H12

12 hours

PERIOD_D1

1 day

PERIOD_W1

1 week

PERIOD_MN1

1 month


Through code you can create custom ones, e.g. 20 seconds or 1.5 minutes (90 seconds). But that would lead to more complex and extensive coding. My advice is to use any of the predefined ones.

 
Miguel Angel Vico Alba #:

Hi Jeff,

you don't mention which language you use (MQL4 or MQL5). I will assume you are talking about MQL5.

The predefined timeframes are these and they work as it is obvious both in the strategy tester and live.

ID

Description

PERIOD_CURRENT

Current timeframe

PERIOD_M1

1 minute

PERIOD_M2

2 minutes

PERIOD_M3

3 minutes

PERIOD_M4

4 minutes

PERIOD_M5

5 minutes

PERIOD_M6

6 minutes

PERIOD_M10

10 minutes

PERIOD_M12

12 minutes

PERIOD_M15

15 minutes

PERIOD_M20

20 minutes

PERIOD_M30

30 minutes

PERIOD_H1

1 hour

PERIOD_H2

2 hours

PERIOD_H3

3 hours

PERIOD_H4

4 hours

PERIOD_H6

6 hours

PERIOD_H8

8 hours

PERIOD_H12

12 hours

PERIOD_D1

1 day

PERIOD_W1

1 week

PERIOD_MN1

1 month


Through code you can create custom ones, e.g. 20 seconds or 1.5 minutes (90 seconds). But that would lead to more complex and extensive coding. My advice is to use any of the predefined ones.

Hi Miguel,

Thank you for your response : )

I am using MT4 which has many fewer "standard" time frame options.  It's good to know this is an area that has improved in MT5.

For the moment I am assuming that EAs will not run on non-standard time frames in MT4.

 
Jeff Kotnik #:

Hi Miguel,

Thank you for your response : )

I am using MT4 which has many fewer "standard" time frame options.  It's good to know this is an area that has improved in MT5.

For the moment I am assuming that EAs will not run on non-standard time frames in MT4.

You can run EAs on non-standard time frames in MT4 using Off-line chart. Please do some researches to find more information.

But I recommend you to switch to MT5, MT4 is obsolete.

 
Alain Verleyen #:

You can run EAs on non-standard time frames in MT4 using Off-line chart. Please do some researches to find more information.

But I recommend you to switch to MT5, MT4 is obsolete.

Thanks Alain.