Strange behavior on indicators related to different timeframe

 

I do not know if it happened to someone, but using an indicator (HLA Indicator) which shows the calculated values ​​of higher timeframe, the value shown in the graph is different from that recovered with the use of the function iCustom. Does anyone know how to fix or if it is a bug?

 

show us picture in the thread -- screen capture software, then put the picture as attachment etc or put some words on top of it to illustrate what are you asking

I do not use HLA indicator

other people don't have idea , and why you have to use MTF if you just wanna to trade

and most of us use only 1 to max 2 TF, i.e. if you are saying 4hr is different from 5 minutes, then of course !! what do you expect

 

...

In cases like that almost always is a wrong iCustom() call (some parameter missed, or mixed up or the type is not specified correctly). Revise your iCustom() call and you will probably find where the error is. If the parameters are passed correctly, the value must be the same

Dainesi:
I do not know if it happened to someone, but using an indicator (HLA Indicator) which shows the calculated values ​​of higher timeframe, the value shown in the graph is different from that recovered with the use of the function iCustom. Does anyone know how to fix or if it is a bug?
 

...

PS: if the "HLA indicator" is the one from this post https://www.mql5.com/en/forum/173439/page115 then the correct call should be something like this (passing all the parameters just in order to show that even the parameter that does not do anything (the 2nd and the 4th) must be passed in a iCustom() call otherwise you will get unpredictable results) :
iCustom(NULL,TargetTimeFrame,"High-Low Activator Vs. 1.1",MAPeriod,"",MAMethod,"","",0,shift);
 

The code, inside the EA, is the following

/*

MAPeriodUTF = 3

MAMethodUTF = 0

TimeFrameUTF = "H4"

*/

double S0 = iCustom(Symbol(),Period(),IndName,MAPeriodUTF,"-",MAMethodUTF,"-",TimeFrameUTF,0,0);

[/CODE]

While the first few lines of the source of the indicator are as follows:

[CODE]#property indicator_buffers 1

#property indicator_color1 Gold

#property indicator_width1 2

#property indicator_style1 STYLE_SOLID

#property indicator_chart_window

//----Extern Variables

extern int MAPeriod = 3;

extern string __________ = "0:Simple, 1:Exponential, 2:Smoothed, 3:Linear";

extern int MAMethod = 0;

extern string _________ = "M0:Current TF - M1 - M5 - M15 - M30 - H1 - H4 - D1 - W1 - MN1";

extern string TimeFrame = "M0";

As you can see passing arguments is correct, but sometimes (not always) the value returned by the code (via iCustom) is different from what you see on the screen through the window "data" of MetaTrader4.

Note that if you insert the TF current, the values ​​are correct. And only sometimes on other TF values ​​are wrong. Only sometimes. This is the problem.

 

That indicator has some issues

Try using this version

Dainesi:
The code, inside the EA, is the following

/*

MAPeriodUTF = 3

MAMethodUTF = 0

TimeFrameUTF = "H4"

*/

double S0 = iCustom(Symbol(),Period(),IndName,MAPeriodUTF,"-",MAMethodUTF,"-",TimeFrameUTF,0,0);

[/CODE]

While the first few lines of the source of the indicator are as follows:

[CODE]#property indicator_buffers 1

#property indicator_color1 Gold

#property indicator_width1 2

#property indicator_style1 STYLE_SOLID

#property indicator_chart_window

//----Extern Variables

extern int MAPeriod = 3;

extern string __________ = "0:Simple, 1:Exponential, 2:Smoothed, 3:Linear";

extern int MAMethod = 0;

extern string _________ = "M0:Current TF - M1 - M5 - M15 - M30 - H1 - H4 - D1 - W1 - MN1";

extern string TimeFrame = "M0";

As you can see passing arguments is correct, but sometimes (not always) the value returned by the code (via iCustom) is different from what you see on the screen through the window "data" of MetaTrader4.

Note that if you insert the TF current, the values ​​are correct. And only sometimes on other TF values ​​are wrong. Only sometimes. This is the problem.
 

Nothing to do!

Each time the test run, the values ​​read by the code are different from those shown on the graph.

I do not know exactly what to do.

To test what I say, just insert into a routine, or start, the following lines of code and check the correspondence of what is written in the data window and what appears in the upper left of the graph (where the function Comment() works).

double F0 = iCustom(Symbol(),Period(),"High-Low Activator Vs. 1.101",3,"-",0,"-","M0",0,0);

double S0 = iCustom(Symbol(),Period(),"High-Low Activator Vs. 1.101",3,"-",0,"-","H4",0,0);

string msg = "Fast: " + DoubleToStr(F0,4) + " Slow0: " + DoubleToStr(S0,4);

Comment(msg);
 

...

Here is how that example of yours looks at my PC

As you can see it is showing correct values (so all is OK with your example)

Dainesi:
Nothing to do!

Each time the test run, the values ​​read by the code are different from those shown on the graph.

I do not know exactly what to do.

To test what I say, just insert into a routine, or start, the following lines of code and check the correspondence of what is written in the data window and what appears in the upper left of the graph (where the function Comment() works).

double F0 = iCustom(Symbol(),Period(),"High-Low Activator Vs. 1.101",3,"-",0,"-","M0",0,0);

double S0 = iCustom(Symbol(),Period(),"High-Low Activator Vs. 1.101",3,"-",0,"-","H4",0,0);

string msg = "Fast: " + DoubleToStr(F0,4) + " Slow0: " + DoubleToStr(S0,4);

Comment(msg);
Files:
compared.gif  59 kb
 
Dainesi:
Does anyone know how to fix or if it is a bug?

Hi, it is a BUG of Metatrader 4, unfortunately.

One year ago I discovered this strange behavior of iCustom ().

If your EA uses the values ​​of an indicator that works on a timeframe DIFFERENT from that where your EA works:

- in LIVE (demo, real) the EA works, so in LIVE you can use iCustom () which calls an indicator that calculates the values ​​to a different timeframe from that where the EA runs,

- but in BACKTEST or in OPTIMIZATION the EA DOES NOT WORK: if your EA uses iCustom() which calls an indicator that works on different timeframe from that used in your backtest/optimization... the EA DOES NOT WORK.

- In BACKTEST or in OPTIMIZATION you can use an EA that uses iCustom () that calls an indicator that works ONLY ON THE SAME timeframe of your backtest/optimization.

The only way to solve this problem/BUG is to encode the indicator inside the EA, without using iCustom ()

 
mladen:
Here is how that example of yours looks at my PC
As you can see it is showing correct values (so all is OK with your example)

Unfortunately, what you see on the screen (lines indicators) is correct but what is from interrogation by iCustom is often wrong. Looking how to solve, with unconventional way, I have found a workaroundthat ... it works!

I entered, in the code of the indicator, the creation of two graphic objects (rectangles point) with time and price equal to the value of the indicator offset 0 and 1.

From my EA I seek these objects and I find the position of obtaining the data, correct, searched!

P.S. Obviously, in order to do that, we need to have the code of the indicator.

Reason: