Indicators Optimized for Offline Charts - page 3

 
mladen:
One way of looking at it

Simply, some built functions that are working correctly (and used to work correctly in older builds of metatrader) are not working as they used to (correctly). My guess is that since metatrader 5 never had offline charts and sine they are merging metatrader 4 and metatrader 5, what we are seeing are errors when using metatrader 5 machine on a thing that it (metatrader 5) never could do

And that would mean that we are going to wait for a long time for error corrections (I remember that iStdevOnArry() was working wrong for at least 4 years even though metatrader was notified of the error)

Hi,

please can you coders explain with an example how to cheat this bars control?

Ovo said to me "You may avoid it only if you recode the indicator and avoid MQL detection of changed bars." Ok, i'm an ass in coding yet, but i just want to understand if this detection of changed bars has something to do with this phase of code or not.

int i,r,counted_bars=IndicatorCounted();

if(counted_bars < 0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

if (returnBars) { dihuu[0] = MathMin(limit+1,Bars-1); return(0); }

if (ArrayRange(trend,0)!=Bars) ArrayResize(trend,Bars);

Is it here that we should to change or is it a more complex thing? It's really an hell now to handle an offline chart in metatrader with even only one indicator attached...

 
thefxpros:
Hi,

please can you coders explain with an example how to cheat this bars control?

Ovo said to me "You may avoid it only if you recode the indicator and avoid MQL detection of changed bars." Ok, i'm an ass in coding yet, but i just want to understand if this detection of changed bars has something to do with this phase of code or not.

int i,r,counted_bars=IndicatorCounted();

if(counted_bars < 0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

if (returnBars) { dihuu[0] = MathMin(limit+1,Bars-1); return(0); }

if (ArrayRange(trend,0)!=Bars) ArrayResize(trend,Bars);
Is it here that we should to change or is it a more complex thing? It's really an hell now to handle an offline chart in metatrader with even only one indicator attached...

thefxpros

Please read these posts : https://www.mql5.com/en/forum/184321

Since it was already mentioned that it is easy and it is just some little trick, I would prefer if someone else shows it (I explained my point of view in second post from that link)

 

Fix offline chart refresh ( speed up )

Offline charts have a problem when are update with win32 hack. They force to indicator to update all bars. This class fix this problem. Only refresh new bars. This speed up very much MT4. In my test with backtest and 5 offline charts updated at same time, all charts are refresh without drop ticks.

You only have replace:

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit=MathMin(Bars-counted_bars,Bars-1);

for this:

If you use "for( i=limit-1..."

int limit = Bar::tick();

or If you use "for( i=limit..."

int limit = Bar::tick() - 1;

PS: I test this with indicator i use and all is fine. Many indicators are this web.

bar.mqh

Files:
bar.mqh  2 kb
 
braintheboss:
Offline charts have a problem when are update with win32 hack. They force to indicator to update all bars. This class fix this problem. Only refresh new bars. This speed up very much MT4. In my test with backtest and 5 offline charts updated at same time, all charts are refresh without drop ticks.

Hi thanks a lot!

let's see if i got correctly. All i need to do is to put this file into MQL4/Include folder and then i have to replace that code in the indicators that i want to use on offline charts, right?

 
thefxpros:
Hi thanks a lot! let's see if i got correctly. All i need to do is to put this file into MQL4/Include folder and then i have to replace that code in the indicators that i want to use on offline charts, right?

Yes but you can use it in real charts too. Only if indicator use diferent bar calculation you must adapt some the code. An example is allaverages3.1.

A weird problem is sometimes when you load MT4 and load templates indicator not show correct values and you must load template again. But not logic for this bug because code is very simple and not modify indicator logic...

 

I found problem with refresh indicators when load MT4 or change profile. When you use option "refresh" from context-menu you simulate same update than win32 hack. Problem is invoke "onstart" like when send tick and not way for know when must reset counter bars in class. Then class think is tick event and don't refresh all bars.

I will search way for get solution but i think no clean way.

 
braintheboss:
I found problem with refresh indicators when load MT4 or change profile. When you use option "refresh" from context-menu you simulate same update than win32 hack. Problem is invoke "onstart" like when send tick and not way for know when must reset counter bars in class. Then class think is tick event and don't refresh all bars. I will search way for get solution but i think no clean way.

i'm going to make a killing in the metaquote offices...

So, you're saying to not use your trick for now?

thanks

 
thefxpros:

i'm going to make a killing in the metaquote offices...

So, you're saying to not use your trick for now?

thanks

You can use it without problems. I only did test with backtest and i think only have this problem there and only if offline chart is opened. If you reload template or open new offline chart when you load MT4 not problem. It's only a bug a little annoying.

PS: I have some ideas for fix but now it's only a fast patch for i can use backtest with less cpu.

 
braintheboss:
You can use it without problems. I only did test with backtest and i think only have this problem there and only if offline chart is opened. If you reload template or open new offline chart when you load MT4 not problem. It's only a bug a little annoying. PS: I have some ideas for fix but now it's only a fast patch for i can use backtest with less cpu.

Hi, i'm going to apply your fix to all indicators i use. Could you please give me some help?

1) With constructs like this:

int i, shift, limit, counted_bars=IndicatorCounted();

if (counted_bars > 0) limit = Bars - counted_bars - 1;

if (counted_bars < 0) return(0);

if (counted_bars < 1)

{

limit = Bars - 1;

for(i=0;i<Bars;i++)

{

Line = EMPTY_VALUE;

upTrend1 = EMPTY_VALUE;

upTrend2 = EMPTY_VALUE;

}[/CODE]

How it would be the modification?

2) I have a lot of MTF indicators made by icustom funcion that need a source indicator in order to work. In this mtf indicators i have this type of code:

[CODE]int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);

limit= MathMin(Bars-counted_bars+3*TimeFrame/Period(),Bars-1);

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++;

What should i do here?

thanks for your time.

 

Here is the rounded moving average optimized for offline charts (it will work on regular charts too, the same as before, but will work much faster on offline charts) : mar_1.01.ex4

Files:
mar_1.01.ex4  16 kb
mar_2.gif  78 kb
Reason: