I haven't read your code totally I was just looking for the use of 'future' bars ..[bar-??] for calculation that aren't defined:
.. for(i=1;i<=draw_begin;i++) { MA[Bars-i]=iMA(NULL,TimeFrame,1,0,0,MAPrice,Bars-i); Up[Bars-i]=EMPTY_VALUE; Dn[Bars-i]=EMPTY_VALUE; ..
Try to search from there.
Be aware that this (calculation of a value with a 'future-bar') can produce the typical 're-painting' indicators!
Gooly
your code cannot be compiled
how do you think that someone is gonna spend his time to fix so many error before trying to get to the bottom of your problem
To avoid re-painting, should we have some sort comparison or something like that?
Make sure that prev. calculated bars aren't recalculated with new Bars:
1) Start checking whether (s.a.) Value1[Bar] = func( Value2[Bar-x] ).
2) Check whether the loop is going from now to the beginning of the chart (dangerous) or the opposite way (saver).
3) Place an arrow at the indicator-price of a time(!) defined bar (if Time[x] == D'...') whenever the indicator-value of this bar is calculated: is it always at the same place or is it 'moving' and you see many arrows stacked at the same bar?
Sometimes it is hidden pretty well in the code either by purpose or by unthoughtfulness.
Gooly..@qjol sorry I could not fit all the code in here, so if you compile this it wont work. The code itself gives no errors.
If anyone is interested in he indicator I have attached a copy.
I think this is very handy multi-MA indicator for automated systems. For emable T3 (code:11) gives very smooth signals that are easy to incorporate into an EA strategy!
@gooly thank you very much for your advice!
Unfortunately my programming skills and understanding of the syntax is very rudimentary, and I don't think I can understand the code enough to solve the problem.
@gooly thank you very much for your advice!
Unfortunately my programming skills and understanding of the syntax is very rudimentary, and I don't think I can understand the code enough to solve the problem.
Just look at ITrend(..):
double ITrend(double price[],double array[],int per,int bar) { double alfa = 2.0/(per+1); if(bar > 7) double it = (alfa - 0.25*alfa*alfa)*price[bar]+ 0.5*alfa*alfa*price[bar-1]-(alfa - 0.75*alfa*alfa)*price[bar-2]+ 2*(1-alfa)*array[bar-1] - (1-alfa)*(1-alfa)*array[bar-2]; else it = (price[bar] + 2*price[bar-1]+ price[bar-2])/4; return(it); }
For the e.g. 1-min Bar at 12:30 you the values of the bars 12:31 and 12:32,
But this at least seams to be easy to repair: replace [bar] => [bar+2], [bar-1] => [bar+1] and [bar-2] => [bar] :
// MA_Method=12: ITrend - Instantaneous Trendline by J.Ehlers double ITrend(double price[],double array[],int per,int bar) { double alfa = 2.0/(per+1); /* original if(bar > 7) double it = (alfa - 0.25*alfa*alfa)*price[bar]+ 0.5*alfa*alfa*price[bar-1]-(alfa - 0.75*alfa*alfa)*price[bar-2]+ 2*(1-alfa)*array[bar-1] - (1-alfa)*(1-alfa)*array[bar-2]; else it = (price[bar] + 2*price[bar-1]+ price[bar-2])/4; */ if(bar > 7) double it = (alfa - 0.25*alfa*alfa)*price[bar+2]+ 0.5*alfa*alfa*price[bar+1]-(alfa - 0.75*alfa*alfa)*price[bar]+ 2*(1-alfa)*array[bar+1] - (1-alfa)*(1-alfa)*array[bar]; else it = (price[bar+2] + 2*price[bar+1]+ price[bar])/4; return(it); }
Without testing (!) I think it should be the same but now you'll get the vertical lines at the first bars of the chart (way back in the past) or you start calc at Bars - 3.
Gooly
Thank you gooly,
seems like your fix did away with repainting! :)
I attached the fixed version in case some finds this indicator useful.
I like trading it with 25-50 tick volume bars (using custom script to convert time chart to volume) as well as using it with EAs, it gives very clean and clear signals due to the exponential smoothing
..actually the repainting on the recent bar is still there... :(
I changed:
/* if(bar > 7) // This will repaint! replaced by code below double it = (alfa - 0.25*alfa*alfa)*price[bar]+ 0.5*alfa*alfa*price[bar-1]-(alfa - 0.75*alfa*alfa)*price[bar-2]+ 2*(1-alfa)*array[bar-1] - (1-alfa)*(1-alfa)*array[bar-2]; else it = (price[bar] + 2*price[bar-1]+ price[bar-2])/4; return(it); */ //------------- if(bar > 7) double it = (alfa - 0.25*alfa*alfa)*price[bar+2]+ 0.5*alfa*alfa*price[bar+1]-(alfa - 0.75*alfa*alfa)*price[bar]+ 2*(1-alfa)*array[bar+1] - (1-alfa)*(1-alfa)*array[bar]; else it = (price[bar+2] + 2*price[bar+1]+ price[bar])/4; return(it);
To be clear if the value of the last, most recent bar changes which hasn't closed yet - that is not re-painting!
That's why one either trades on the open of a new bar or you wait until the bar is 'close to close' e.g. 5min-bar and 90% = 30sec left to finish.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
not sure if I'm posting on right place...
I have a problem with one of my favorite custom indicators.
This multiple MA indicator is drawing a vertical line at the current bar! All this started to happen after the infamous ver 600 MT4 update that messed up a lot of thing for many people
Code:"