Kwan_indicator
Download scriptThis indicator is designed to analyze market trends by synthesizing three distinct technical oscillators into a single, smoothed visual output. Rather than relying on a single metric, it creates a composite value that attempts to capture the relationship between momentum, relative strength, and stochastic volatility.
Core Data Processing
The script begins by gathering data from three primary sources over a set period (defaulting to the last 1,000 bars):
- Stochastic Oscillator: Measures the current price relative to its high/low range over a specific lookback period.
- Relative Strength Index (RSI): Evaluates the speed and change of price movements to identify overbought or oversold conditions.
- Momentum: Tracks the rate of change in price movement.
The Calculation Logic
The tool combines these three elements into a unique proprietary formula. It multiplies the Stochastic value by the RSI value, then divides that product by the Momentum figure. By performing this calculation, the indicator essentially "weights" the strength of the current move against its historical volatility and speed. This allows the tool to highlight where the market is gaining significant traction while filtering out minor fluctuations.
Smoothing and Trend Identification
Once the raw composite values are calculated, the script applies an additional layer of processing to make the data readable for a human trader:
- Moving Average: It takes a Simple Moving Average (SMA) of the composite formula to smooth out any "noise" or jagged edges in the data.
- Directional Filtering: The script then separates this smoothed data into two distinct visual lines based on their direction:
- If the value is increasing compared to the previous point, it is plotted as one specific trend line (Blue).
- If the value is decreasing, it is plotted as a different trend line (Red).
Visual Output
For the user, this results in a clear visual representation of market direction. Instead of seeing a chaotic mix of multiple indicators, the trader sees a streamlined view where the primary goal is to identify whether the calculated "strength" of the price movement is currently trending upward or downward.
#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 2
#property indicator_color1 Blue
#property indicator_color2 Red
extern int Count_Bars=1000;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double Formula[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator drawing
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);
SetIndexBuffer(1,ExtMapBuffer3);
SetIndexStyle(2,DRAW_NONE,STYLE_SOLID,3,Yellow);//DRAW_NONE,EMPTY,EMPTY);
SetIndexBuffer(2,ExtMapBuffer2);
SetIndexBuffer(3,Formula);
///-----Name of Indicator
string short_name = "ZigZag BETA Current value calculated by indicator:";
IndicatorShortName(short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int pos=0;
if (Count_Bars>Bars) {pos=Bars;}else{pos=Count_Bars;}
int temp=pos;
while(pos>=0)
{
//string xxx = "pos";
double Stoch = iStochastic(NULL,0,9,6,2,MODE_SMA,1,0,pos);
double RSI = iRSI(NULL,0,9,PRICE_CLOSE,pos);
double moment = (iMomentum(NULL,0,9,PRICE_CLOSE,pos));
//Main Forumla
//double preFormula = (/Momentum);
if (moment != 0)
ExtMapBuffer2[pos] = Stoch*(RSI)/moment;
//Alert("MACD: ", MACD," ","Stoch: ", Stoch," ", "RSI: ", RSI," ","Momentum: ", momentum," ","Volume: ", Volu);
//Alert(Stoch*(RSI)/Roc);
pos--;
}
while (temp >=0) {
ExtMapBuffer1[temp]=EMPTY_VALUE;
ExtMapBuffer3[temp]=EMPTY_VALUE;
Formula[temp] = iMAOnArray(ExtMapBuffer2,0,2,0,MODE_SMA,temp);
if (Formula[temp]>Formula[temp+1]){
ExtMapBuffer1[temp] = Formula[temp];
if (ExtMapBuffer1[temp+1]==EMPTY_VALUE) ExtMapBuffer1[temp+1]=Formula[temp+1];
}else{
ExtMapBuffer3[temp] = Formula[temp];
if (ExtMapBuffer3[temp+1]==EMPTY_VALUE) ExtMapBuffer3[temp+1]=Formula[temp+1];
}
temp--; }
//----
return(0);
}
//+------------------------------------------------------------------+
Comments