Download MetaTrader 5
To add comments, please log in or register
Enable MQL5 Storage to store your source codes. It is free!
Scarlett
34
Scarlett 2014.07.24 14:35 

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?

honest_knave
964
honest_knave 2014.07.24 15:01  

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

qjol
3243
qjol 2014.07.24 15:22  
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


qjol
3243
qjol 2014.07.24 15:32  
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

Scarlett
34
Scarlett 2014.07.24 16:22  
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?

qjol
3243
qjol 2014.07.24 16:34  

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);
honest_knave
964
honest_knave 2014.07.24 17:03  

My apologies - thank you for the correction.

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

Scarlett
34
Scarlett 2014.07.24 17:18  
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

qjol
3243
qjol 2014.07.24 17:24  

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);
Scarlett
34
Scarlett 2014.07.24 20:03  
I call candle 0 current candle and candle 1 last candle since it's the last one that ended
/
To add comments, please log in or register