MBA_Thesis_Indicator_ok_v1
Download scriptThis script is designed as a specialized technical analysis tool for the MetaTrader 4 platform. Its primary purpose is to synthesize several different market indicators into a single, unified visual representation to help traders identify trends and potential momentum shifts.
How the Logic Works
The core logic of this tool operates in three distinct stages:
1. Data Aggregation Instead of relying on just one piece of information, the script simultaneously calculates four different market metrics:
- MACD: Measures the relationship between two moving averages to identify trend strength.
- Stochastic Oscillator: Evaluates whether a price is overbought or oversold relative to its recent range.
- RSI (Relative Strength Index): Tracks the speed and magnitude of recent price changes.
- Momentum: Measures the rate of change in price.
2. The Custom Calculation The script takes these four individual metrics and combines them into a unique mathematical formula. Specifically, it adds the MACD and RSI values together, multiplies that sum by the Stochastic value, and then divides the entire result by the Momentum value. This creates a customized "composite" value that attempts to capture a broader market sentiment than any single indicator could provide on its own.
3. Smoothing and Visualization To make the final data easier for a human to read (as raw calculations can often be "choppy" or jump around erratically), the script performs two final steps:
- Smoothing: It applies a Moving Average to the composite value calculated in the previous step. This cleans up the noise and provides a smoother line.
- Trend Directional Coloring: The tool then analyzes whether this smoothed value is rising or falling compared to the previous candle.
- If the value is increasing, it highlights the data in one color (Green).
- If the value is decreasing, it shifts the highlight to another color (Yellow).
Summary for the User
Essentially, this tool acts as a "filter." It gathers a wide variety of technical data, processes it through a specific formula, smooths out the fluctuations, and then provides you with a visual histogram. By looking at the color changes and the movement of the bars, you can more easily see the underlying direction of the market's momentum.
#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 Yellow
#property indicator_color3 White
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 1
//---- 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:";
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