MBA
Download scriptThis custom indicator is designed to provide traders with a synthesized visual signal by combining four distinct market analysis tools into a single, cohesive output. Rather than forcing you to monitor multiple separate windows and charts, this script merges the data points to highlight momentum trends and potential reversals.
How the Logic Works
The tool operates through a three-step calculation process:
1. Multi-Indicator Synthesis The script begins by gathering real-time data from four primary technical indicators:
- MACD (Moving Average Convergence Divergence): Measures trend strength and direction.
- Stochastic Oscillator: Identifies overbought or oversold conditions.
- RSI (Relative Strength Index): Evaluates the speed and change of price movements.
- Momentum: Tracks the rate of change in price.
The script then performs a mathematical fusion of these four values. Specifically, it combines the MACD and RSI figures, multiplies them by the Stochastic value, and divides the result by the Momentum value. This creates a unique "composite score" that represents the combined market sentiment.
2. Smoothing the Data To ensure that the visual output is not overly volatile or "choppy," the script applies a Moving Average to the composite score calculated in the first step. This smoothing effect filters out minor price noise, making it easier for a trader to identify the primary underlying trend of the combined data.
3. Visual Directional Mapping Finally, the indicator translates these calculations into a clear visual format:
- It compares the current smoothed value against the previous value.
- If the value is rising, it highlights the data point in one color (Green).
- If the value is falling, it highlights the data point in a different color (Yellow).
Summary for the Trader
The primary goal of this script is to simplify decision-making. By merging momentum, strength, and oscillator data into a single histogram, it provides a streamlined view of market dynamics. When you see the colors shifting, it indicates a change in the collective trend based on the combined behavior of four different technical metrics simultaneously.
//+------------------------------------------------------------------+
//| |
//| Copyright © 1999-2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.ru |
//+------------------------------------------------------------------+
#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