Hi, all:
I want to calculate the WPR value of a detrended price series.
First, I use an indicator buffer to store the detrended price series. But to simplify the question, I directly transfer the raw prices to the buffer.
Export the so called "detrended price series" into the chart, we can see it's exactly the same as the raw prices.(see below)
You need to show your code . . . where does the value for DtdValue[] come from ?
the code:
int start() { //---- int limit,i; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- Detrended Signal Computing switch(LM_Mode) { case 0: //-------Basic Signal (No Local Mean) for(i=0; i<limit; i++) { LM[i]=0; DtdValue[i]=Close[i] - LM[i]; } break; }
"LM_Mode" is the variable I use to choose the algorithm of Local Mean computing, as I said before here i used 0 value which stand for no local mean.
thank you for the attention
the rest of it
#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red //---- extern int LM_Mode = 0; extern int Smooth_Period = 14; extern int Osc_Period = 18; extern int Shift_Period = 11; //---- buffers double LM[]; double DtdValue[]; double DtdOsc[]; double DtdValueMin[]; double DtdValueMax[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(5); //---- indicator line SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, DtdOsc); SetIndexBuffer(1, DtdValue); SetIndexBuffer(2, LM); SetIndexBuffer(3, DtdValueMax); SetIndexBuffer(4, DtdValueMin); //---- SetIndexDrawBegin(0, Smooth_Period+Shift_Period); //---- return(0); }
Hi, all:
I want to calculate the WPR value of a detrended price series.
First, I use an indicator buffer to store the detrended price series. But to simplify the question, I directly transfer the raw prices to the buffer.
Export the so called "detrended price series" into the chart, we can see it's exactly the same as the raw prices.(see below)
Shouldn't this . . .
DtdOsc[i] = 0.02*((DtdValue[i]-DtdValueMin[i])/(DtdValueMax[i]-DtdValueMin[i])*100-50);
. . . be this . . .
DtdOsc[i] = 0.02*( ( DtdValueMax[i] - DtdValueMin[i] ) / ( DtdValueMax[i] - DtdValueMin[i] ) * 100 - 50);
. . ?
From here: https://www.metatrader5.com/en/terminal/help/indicators/oscillators/wpr
%R = (HIGH(i-n)-CLOSE)/(HIGH(i-n)-LOW(i-n))*100
Shouldn't this . . .
. . . be this . . .
. . ?
From here: https://www.metatrader5.com/en/terminal/help/indicators/oscillators/wpr
Please check as this will be always 1.0:
( DtdValueMax[i] - DtdValueMin[i] ) / ( DtdValueMax[i] - DtdValueMin[i] )
may be you meant
( DtdValueMax[i] - DtdValue[i] ) / ( DtdValueMax[i] - DtdValueMin[i] )
?
Gooly
Please check as this will be always 1.0:
may be you meant
?
Shouldn't this . . .
. . . be this . . .
. . ?
From here: https://www.metatrader5.com/en/terminal/help/indicators/oscillators/wpr
Ah yes, well spotted
Hi,RaptorUK:
the exact WPR formula is : -1*(DtdValueMax[i] - DtdValue[i] ) / ( DtdValueMax[i] - DtdValueMin[i] )
so I use the code below:
DtdOsc[i] = 0.02*(-1*(DtdValueMax[i]-DtdValue[i])/(DtdValueMax[i]-DtdValueMin[i])*100-50);
- 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, all:
I want to calculate the WPR value of a detrended price series.
First, I use an indicator buffer to store the detrended price series. But to simplify the question, I directly transfer the raw prices to the buffer.
Export the so called "detrended price series" into the chart, we can see it's exactly the same as the raw prices.(see below)
Now, the question is how can I use an effective way to calculate the WPR value of the detrended price series.
Because there is no "OnArray" function to use, I guess the only way is to write "for" code to directly calculate the value.
Below is the code I use:
You can see that there is a "for" circle in another "for" circle, which is not a fast algorithm I think.
And the result is odd.......
Theoretically, the calculated result should be exactly the same as iWPR in the MT4.
But the result is not the same, so there must be errors.
And I can't find it, so if anyone had think about this question before, pls HELP!
saji