Universal Oscillator Indicator For MT5
The Universal Oscillator Indicator For MT5 is an indicator which is an excellent resource to have when evaluating certain conditons within the markets with the main purpose to identify strong selling and buying opportunities - a type of indicator which helps with this alot is usually an oscillator indicator which shows the up and down cycles of every trend in the market therefore proving the trader with clear insights as to when reversals are most likely to occur. This indicator is essentially a collection of all the high performing oscillators in the markets combined into one indicator which comes with three separate indicator windows - from the top window the trader will see a Universal Oscillator indicator which represents the Relative Strength Index data using red and blue clouds for market directional strength and a set of bands which are like Bollinger Bands, then below that is the Universal Oscillator of the Moving Average Convergence Divergence indicator which also has shaded red and blue areas to show up and down cycle momentum or intensity as well as a Bollinger Bands and then there is a Commodity Channel Index indicator at the very bottom. Therefore the trader may use all sets of indicators within this one indicator to validate bullish and and bearish reversal trade setups.
Installing the Universal Oscillator Indicator For MT5
After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file universaloscillator.mq5 into the folder MQL5\Indicators of your MT5 installation. After that please restart MT5 and then you will be able to see the indicator in the list of indicators.
Parameters of the Universal Oscillator Indicator For MT5
The Universal Oscillator Indicator For MT5 has 12 parameters to configure.
input OSCILLATOR_NAME InpOscillator = RSI; // Oscillator
input int InpOscPeriod1 = 14; // Period
input ENUM_APPLIED_PRICE InpAppliedPrice = PRICE_CLOSE; // Applied price
input DRAW_MODE InpDrawMode = FILLING; // Draw Mode
input LEVEL_MODE InpLevelsMode = BB_MODE; // Levels Mode
input int InpLevelsPeriod = 50; // Levels Period
input double InpLevelsIndent = 2.0; // Levels Indent / Deviation
input bool InpIndentAutoCorrection = true; // Levels Auto Correction
input string InpDivider = "---For Stochastic or MACD---"; // Just Divider NOT Parameter
input int InpOscPeriod2 = 3; // Stoch %D / MACD Slow EMA
input int InpOscPeriod3 = 3; // Stoch Slowing / MACD Signal
input ENUM_STO_PRICE InpStochPrice = STO_LOWHIGH; // Stochastic Price
Buffers of the Universal Oscillator Indicator For MT5
The Universal Oscillator Indicator For MT5 provides 9 buffers.
SetIndexBuffer(0, ExtBuffer1, INDICATOR_DATA);
SetIndexBuffer(1, ExtBuffer2, INDICATOR_DATA);
SetIndexBuffer(2, ExtBuffer3, INDICATOR_DATA);
SetIndexBuffer(3, ExtBuffer4, INDICATOR_DATA);
SetIndexBuffer(4, ExtBuffer5, INDICATOR_DATA);
SetIndexBuffer(5, ExtBuffer6, INDICATOR_DATA);
SetIndexBuffer(2, ExtBuffer3, INDICATOR_DATA);
SetIndexBuffer(2, ExtBuffer3, INDICATOR_COLOR_INDEX);
SetIndexBuffer(2, ExtBuffer3, INDICATOR_DATA);
Main Parts Of The Code
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
int startBar, calculated, toCopy;
//---
if ( rates_total lt minRequiredBars ) {
Print("Not enough bars for calculation.");
return(0);
}
//---
calculated = BarsCalculated(oscHandle);
if ( calculated lt rates_total ) {
Print("Not all data of oscHandle is calculated (", calculated, " bars. Error #", GetLastError());
return(0);
}
//---
if ( prev_calculated gt rates_total || prev_calculated lt = 0 ) {
startBar = minRequiredBars;
toCopy = rates_total;
} else {
startBar = prev_calculated - 1;
toCopy = rates_total - prev_calculated;
if ( prev_calculated gt 0 ) {
toCopy += 1;
}
}
//---
if ( CopyBuffer(oscHandle, 0, 0, toCopy, ExtBuffer1) lt = 0 ) {
Print("Getting Oscillator is failed. Error #", GetLastError());
return(0);
}
//---
if ( InpLevelsMode != CONST_VALUE_MODE ) {
SimpleMAOnBuffer(rates_total, prev_calculated, oscPeriod1+levelsPeriod, levelsPeriod, ExtBuffer1, ExtBuffer2);
}
//---
for ( int bar = startBar; bar lt rates_total; bar++ ) {
double value, sum = 0.0;
double middleLine, indent;
//---
switch ( InpLevelsMode ) {
case MA_MODE:
middleLine = ExtBuffer2[bar];
indent = levelsIndent;
break;
case BB_MODE:
middleLine = value = ExtBuffer2[bar];
for ( int i = bar - levelsPeriod + 1; i lt = bar; i++ ) {
sum += MathPow(ExtBuffer1[i]-value, 2);
}
indent = levelsIndent * MathSqrt(sum/levelsPeriod);
break;
case CONST_VALUE_MODE:
default:
middleLine = ExtBuffer2[bar] = midValue;
indent = levelsIndent;
break;
}
//---
switch ( InpDrawMode ) {
case LINE:
ExtBuffer3[bar] = middleLine + indent;
ExtBuffer4[bar] = middleLine - indent;
break;
case FILLING:
ExtBuffer3[bar] = middleLine;
ExtBuffer4[bar] = middleLine + indent;
ExtBuffer5[bar] = middleLine - indent;
break;
case HISTOGRAM:
if ( ExtBuffer1[bar] gt = ExtBuffer2[bar] ) {
ExtBuffer3[bar] = 0;
} else {
ExtBuffer3[bar] = 1;
}
ExtBuffer4[bar] = middleLine;
ExtBuffer5[bar] = middleLine + indent;
ExtBuffer6[bar] = middleLine - indent;
break;
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+