Your buffers are not as-series.
iHighest/iLowest is. High/Low/Close is.// ArraySetAsSeries(ExtMainBuffer,false); // ArraySetAsSeries(ExtSignalBuffer,false);
Your buffers are not as-series.
iHighest/iLowest is. High/Low/Close is.thanks whroeder1.
I think i did set them as series above.
Are you saying that I should not?
int start() { //--- int i,k,y,limit,counted_bars=IndicatorCounted(); double stocaMax,stocaMin,sum; if(counted_bars<0) return(-1); if(counted_bars==0) limit=K_Period; else limit=counted_bars-1; ArraySetAsSeries(High,false); ArraySetAsSeries(Low,false); ArraySetAsSeries(Close,false); ArraySetAsSeries(ExtMainBuffer,false); ArraySetAsSeries(ExtSignalBuffer,false); for(i=limit; i<Bars; i++) { y=i-K_Period+1; stocaMax=High[ArrayMaximum(High,K_Period,y)]; stocaMin=Low[ArrayMinimum(Low,K_Period,y)]; ExtMainBuffer[i]=(Close[i]-stocaMin)/(stocaMax-stocaMin)*100; } for(i=limit; i<Bars; i++) { sum=0.0; for(k=0; k<D_Period; k++) sum+=ExtMainBuffer[i-k]; ExtSignalBuffer[i]=sum/D_Period; } //--- return(0); }
iHighest and iLowest are not available in this case.
You should use new MQL4 format.
iHighest and iLowest are not available in this case.
You should use new MQL4 format.
Hi @Naguisa Unada,
thanks for looking into this.
have iHighest and iLowest been deprecated?
if so, why does m4t not say so?
thanks
Hi @Naguisa Unada,
thanks for looking into this.
have iHighest and iLowest been deprecated?
if so, why does m4t not say so?
thanks
No, they are invalid in this case, i.e., they can not be used when "false" is specified in "ArraySetAsSeries". Usually, "true" is specified in default.
No, they are invalid in this case, i.e., they can not be used when "false" is specified in "ArraySetAsSeries". Usually, "true" is specified in default.
thanks @Naguisa Unada.
I sent you a message :)
> y=i-InpKPeriod+1; why are you adding 1 at every loop?
> High[ArrayMaximum(High,InpKPeriod,y)]; vs High[iHighest(NULL,0,MODE_HIGH,14,i)]; what s the difference?
> sum+=ExtMainBuffer[i-k]; what is this doing as well?
sum = ExtMainBuffer[i-0] + ExtMainBuffer[i-1] + ExtMainBuffer[i-2] + ExtMainBuffer[i-3] ..........
> You also commented:" No, they are invalid in this case, i.e., they can not be used when "false" is specified in "ArraySetAsSeries". Usually, "true" is specified in default. " where can i find this info?
thanks whroeder1.
I think i did set them as series above.
Are you saying that I should not?
They are not as serie, and should be as serie
// ArraySetAsSeries(ExtMainBuffer,false); // ArraySetAsSeries(ExtSignalBuffer,false);
This is not correct, at each tick, the indicator will be redrawed for all Bars
for(i=limit; i<Bars; i++)
for the rest it should work
This is not correct, at each tick, the indicator will be redrawed for all Bars
for the rest it should work
This is correct, because in my program limit = counted_bars - 1.
> y=i-InpKPeriod+1; why are you adding 1 at every loop?
> High[ArrayMaximum(High,InpKPeriod,y)]; vs High[iHighest(NULL,0,MODE_HIGH,14,i)]; what s the difference?
> sum+=ExtMainBuffer[i-k]; what is this doing as well?
sum = ExtMainBuffer[i-0] + ExtMainBuffer[i-1] + ExtMainBuffer[i-2] + ExtMainBuffer[i-3] ..........
> You also commented:" No, they are invalid in this case, i.e., they can not be used when "false" is specified in "ArraySetAsSeries". Usually, "true" is specified in default. " where can i find this info?
thanks Naguisa :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to recreate the Stochastic for fun.
This should be the formula: %K = (Current Close - Lowest Low)/(Highest High - Lowest Low) * 100
%D = 3-day SMA of %K
However the results of my code does not match the indicator provided by MQL4. can you help me understand where the error is?
This is the bulk of my indicator.
thanks