Running an EA on non standard time frames

 

I wrote an EA that scans multiple currencies and multiple time frames and checks for their Ima values.

The EA works fine, but I want to add non standard time frames to the list of time frames I scan (2 and 8 hours), is it possible?

saw that non standard time frames can be used only on offline charts, but I don't understand how this will work.

Does the offline chart get updated like a regular chart?

Will I need to create the offline charts every time I run the EA?

How do I use an offline chart in my EA?

 

There should not be any need to create offline charts - just make the iMA call.

Example: 

iMA(NULL,PERIOD_H2,13,8,MODE_SMMA,PRICE_MEDIAN,0)

 

From iMA:

timeframe

[in]  Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.

 

From Enum_Timeframes

PERIOD_H2

120

2 hours

PERIOD_H8

480

8 hours

 
sa1221:

I wrote an EA that scans multiple currencies and multiple time frames and checks for their Ima values.

The EA works fine, but I want to add non standard time frames to the list of time frames I scan (2 and 8 hours), is it possible?

yes

saw that non standard time frames can be used only on offline charts, but I don't understand how this will work.

Does the offline chart get updated like a regular chart?

yes

Will I need to create the offline charts every time I run the EA?

yes

how do I use an offline chart in my EA?

depending on what you want to do

if you want to call an indicator do what honest_knave's says above


 
honest_knave:

There should not be any need to create offline charts - just make the iMA call.

Example: 

 

From iMA:

timeframe

[in]  Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.

 

From Enum_Timeframes

PERIOD_H2

120

2 hours

PERIOD_H8

480

8 hours



wrong

this works only if you have generated the Chart (periodconverter) + you must open the generated chart before you trying to use it

 
honest_knave:

There should not be any need to create offline charts - just make the iMA call.

Example: 

 

From iMA:

timeframe

[in]  Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.

 

From Enum_Timeframes

PERIOD_H2

120

2 hours

PERIOD_H8

480

8 hours



When I write for example:

double last_candle_ma_144 = iMA("EURUSD", PERIOD_H2, 144, 0, MODE_SMA, PRICE_CLOSE, 1);

 or any other symbol it returns 0.0

it works only when I use standard time frames.

 

qjol:

wrong

this works only if you have generated the Chart (periodconverter) + you must open the generated chart before you trying to use it


 Can you please explain what exactly I need to do?

 

1) you have to create an offline chart (you can use periodconverter)

2) open the (offline) chart (if you don't open the chart it will return 0.0)

3) then you can use your code:

double last_candle_ma_144 = iMA("EURUSD", PERIOD_H2, 144, 0, MODE_SMA, PRICE_CLOSE, 1);
 

My apologies - thank you for the correction.

I was going off my interpretation of the literature rather than practical experience. 

 
qjol:

1) you have to create an offline chart (you can use periodconverter)

2) open the (offline) chart (if you don't open the chart it will return 0.0)

3) than you can use your code:


Thank you

 

sa1221:

double last_candle_ma_144 = iMA("EURUSD", PERIOD_H2, 144, 0, MODE_SMA, PRICE_CLOSE, 1);


edit: B.T.W. it's not the last candle it's the one before the last

the last candle is:

double last_candle_ma_144 = iMA("EURUSD", PERIOD_H2, 144, 0, MODE_SMA, PRICE_CLOSE, 0);
 
I call candle 0 current candle and candle 1 last candle since it's the last one that ended
Reason: