The CWPROnArray class is intended for calculation of Williams’ Percent Range (%R) on indicator buffers.
Usage:
The Init() method with the following parameters is called in the OnInit() function of the indicator:
- int aPeriod is indicator period.
The Solve() method with the following parameters is called in the OnCalculate() function:
- const int aRatesTotal is the rates_total variable from the OnCalculate() function parameters;
- const int aPrevCalc is the prev_calculated variable from the OnCalculate() function parameters;
- double aDataHigh[] is the buffer with the High data for the indicator calculation;
- double aDataLow[] is the buffer with the Low data for the indicator calculation;
- double aDataClose[] is the buffer with the Close data for the indicator calculation;
- double aWPR[] is the buffer with calculated value of WPR.
Additional methods:
- int BarsRequired() returns the minimal number of bars required for calculation of ADX;
- string Name() returns a string with the indicator name;
The Test_WPROnArray.mq5 file is an indicator demonstrating how to use the CWPROnArray class. The IncWPROnArray file must be located in the MQL5\Include\IncOnArray directory of the terminal data folder (the IncOnArray folder must be created).
Williamsβ Percent Range Technical Indicator (%R) is a dynamic technical indicator, which determines whether the market is overbought/oversold. Williamsβ %R is very similar to the Stochastic Oscillator. The only difference is that %R has an upside down scale and the Stochastic Oscillator has internal smoothing.