3in1_ST_RSI_CCI
Download scriptThis technical tool is designed to provide a comprehensive view of market momentum by consolidating three different popular trading indicators into a single, unified visual display. Rather than looking at these indicators individually, this script merges them to create a "composite" signal, helping traders identify trends with more context.
How the Logic Works
1. The Component Indicators The tool gathers data from three distinct types of technical analysis:
- RSI (Relative Strength Index): Measures the speed and change of price movements to identify overbought or oversold conditions.
- CCI (Commodity Channel Index): Helps identify whether an asset is trading at an extreme distance from its average price.
- Stochastic Oscillator: Compares a particular closing price to its range over a certain period to determine if the price is likely to continue in its current direction or reverse.
2. The Weighted Synthesis The core logic of this script lies in its ability to "mix" these three sources. Instead of letting one indicator dominate the chart, the tool assigns a specific weight (importance level) to each one.
- It calculates a combined value by taking the Stochastic data and adjusting it based on the relative influence you choose for the RSI and CCI.
- This creates a single, smoothed "Sum" line that represents a blended consensus of all three indicators simultaneously.
3. Trend Smoothing (Moving Averages) Once the composite sum is calculated, the tool applies an additional layer of refinement to remove "market noise" (minor, insignificant price fluctuations). It processes the blended data through two different types of Moving Averages:
- Fast Moving Average: Reacts more quickly to recent changes in the combined data.
- Slow Moving Average: Provides a broader, more stable view of the trend.
What This Means for the User
By viewing these lines together, you can see the interaction between short-term momentum and long-term trends. When the fast moving average crosses the slow moving average on this composite line, it indicates a shift in the blended momentum of the market, potentially signaling a change in trend based on the combined intelligence of the RSI, CCI, and Stochastic indicators.
//+------------------------------------------------------------------+
//| 3in1_ST_RSI_CCI.mq4 |
//| Copyright © 2009, BB. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, BB"
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 Brown
#property indicator_level1 0
#property indicator_levelcolor Gray
//#property indicator_width1 2
//---- indicator parameters
extern double weight_cci=0.1; // from 0 to 1
extern double weight_rsi=0.1; // from 0 to 1
extern int CCI = 21; // period
extern int RSI = 21; // period
extern int St_K=24; // Stochastic %K
extern int St_S=10; // Stochastic %K
extern int FastMA=3;
extern int SlowMA=7;
//---- indicator buffers
double SumBuffer[];
double FastMABuffer[];
double SlowMABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(1,SlowMA);
//---- indicator buffers mapping
SetIndexBuffer(0,SumBuffer);
SetIndexBuffer(1,FastMABuffer);
SetIndexBuffer(2,SlowMABuffer);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName(WindowExpertName());
SetIndexLabel(0,WindowExpertName());
SetIndexLabel(1,"Fast MA");
SetIndexLabel(2,"Slow MA");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- DeMarker counted in the 1-st buffer
for(int i=0; i<limit; i++)
{
double rsi = iRSI(Symbol(),0,RSI,PRICE_TYPICAL,i)-50;
double cci = iCCI(Symbol(),0,CCI,PRICE_TYPICAL,i);
double St = iStochastic(NULL, 0, St_K, 3, St_S, 0, NULL, MODE_MAIN, i) - 50;
SumBuffer[i] = St*(1-weight_cci-weight_rsi) + rsi * weight_rsi + cci * weight_cci;
}
//---- signal line counted in the 2-nd buffer
for(i=0; i<limit; i++)
{
FastMABuffer[i]=iMAOnArray(SumBuffer,Bars,FastMA,0,MODE_LWMA,i);
SlowMABuffer[i]=iMAOnArray(SumBuffer,Bars,SlowMA,0,MODE_LWMA,i);
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments