MBA_Thesis_Indicator_ok
Download scriptThis script is a custom technical analysis tool designed for the MetaTrader 4 platform. It functions as a visual indicator that processes multiple market data streams to help identify trends and potential price movements. Instead of relying on a single metric, it synthesizes various mathematical oscillators into a singular, smoothed visual representation.
Core Logic and Data Processing
The script operates by gathering real-time information from four distinct technical indicators:
- MACD (Moving Average Convergence Divergence): Used to identify changes in the strength, direction, and magnitude of price momentum.
- Stochastic Oscillator: Used to determine the relative position of the current price compared to its previous range.
- RSI (Relative Strength Index): Used to measure the speed and change of price movements to identify overbought or oversold conditions.
- Momentum: Used to assess the rate of change in price.
The script combines these values into a specific formula where the Stochastic value is multiplied by the sum of the MACD and RSI, then divided by the Momentum value. This creates a primary "raw" data stream that represents a unique hybrid of market sentiment and velocity.
Smoothing and Trend Visualization
To make this raw data more readable and less "noisy" for the user, the script performs two additional logical steps:
- Moving Average Filtering: The raw hybrid value is passed through a Simple Moving Average (SMA) calculation. This smooths out minor price fluctuations, allowing the indicator to highlight the broader underlying trend more clearly.
- Directional Coloring: Once the smoothed value is calculated, the script evaluates its direction relative to the previous data point.
- If the current value is higher than the previous one, it signals an upward movement (visualized in Green).
- If the current value is lower than the previous one, it signals a downward movement (visualized in Red).
Summary for the User
The end result is a dynamic histogram displayed in a separate window on your chart. It provides a "smoothed" view of market sentiment by blending several different technical perspectives into one visual line. By observing the color shifts between Green and Red, you can more easily identify the prevailing direction of the market trend while filtering out minor market volatility.
#property copyright "Metatrader4 Code by jjk2. Based on MBA Thesis from Simon Fraser University written by C.E. ALDEA."
#property link ""
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 DimGray
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexLabel(2,NULL);
string short_name = "ZigZag BETA Current value calculated by indicator:";
IndicatorShortName(short_name);
return(0);
}
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
int limit;
if (counted_bars<0) return(-1);
if (counted_bars>0) counted_bars--;
limit = Bars-counted_bars;
//
//
//
//
//
for (int i=limit; i>=0; i--)
{
double MACD = iMACD(NULL,0,12,26,9,PRICE_CLOSE,0,i);
double Stoch = iStochastic(NULL,0,9,6,2,MODE_SMA,1,0,i);
double RSI = iRSI(NULL,0,9,PRICE_CLOSE,i);
double moment = iMomentum(NULL,0,9,PRICE_CLOSE,i);
if (moment != 0)
ExtMapBuffer4[i] = Stoch*(MACD+RSI)/moment;
else ExtMapBuffer4[i] = 0.00;
}
//
//
//
//
//
for (i=limit; i>=0; i--)
{
ExtMapBuffer3[i] = iMAOnArray(ExtMapBuffer4,0,2,0,MODE_SMA,i);
if (ExtMapBuffer3[i]>ExtMapBuffer3[i+1]) {
ExtMapBuffer1[i] = ExtMapBuffer3[i];
ExtMapBuffer2[i] = EMPTY_VALUE;
}
else
{
ExtMapBuffer2[i] = ExtMapBuffer3[i];
ExtMapBuffer1[i] = EMPTY_VALUE;
}
}
//
//
//
//
//
return(0);
}
Comments