ind_RSICCIDiv_v1
Download scriptThis script is a custom technical analysis tool designed to identify potential trading opportunities by analyzing price momentum and exhaustion. It works by combining two popular market indicators—the Relative Strength Index (RSI) and the Commodity Channel Index (CCI)—to filter out "noisy" market movements and highlight specific entry points.
The core logic functions through three distinct layers of verification:
1. Momentum and Overbought/Oversold Tracking
The tool constantly monitors the RSI to determine if an asset is being pushed too far in one direction. It uses two different threshold levels for this purpose:
- Primary Levels: These define the "active" zones where a trade might occur (e.g., determining if the price is currently in a strong bullish or bearish state).
- Secondary Zone Tracking: The script keeps a "memory" of whether the asset was recently in an extreme overbought or oversold state. This helps the tool understand the recent history of price exhaustion before making a decision.
2. The Entry Conditions (Buy and Sell Signals)
Instead of giving a signal every time a line crosses a boundary, the script requires a specific "confluence" of events to trigger a visual arrow on your chart:
- For Buy Signals: The script looks for a situation where the RSI shows strong upward momentum, but the CCI indicates that the price has dipped significantly below its normal range. Essentially, it seeks out moments where the overall trend is positive, but a temporary "dip" has occurred that might represent a buying opportunity.
- For Sell Signals: Conversely, the script looks for a situation where the RSI shows strong downward momentum, while the CCI indicates that the price has spiked significantly above its normal range. It identifies these as moments where a temporary "rally" in a downtrend might be an opportunity to sell.
3. Advanced Filtering Logic
To increase accuracy and reduce false signals, the script includes an optional "Zone Check." If enabled, the tool won't just look at the current moment; it checks the recent history of the RSI.
Depending on your settings, you can configure the script to:
- Only fire signals if the price was recently in a specific extreme zone (ensuring you aren't trading into a stale trend).
- Reverse these requirements to suit different trading styles (e.g., looking for "pullbacks" versus "breakouts").
Summary for the User: In plain terms, this script acts as a filter. It waits for the market to show a clear direction (via RSI) and then looks for a specific type of price correction or "stretch" (via CCI). When these two conditions meet—combined with a check on recent historical extremes—it places an arrow on your chart to suggest a potential entry point.
//+------------------------------------------------------------------+
//| ind_RSICCIDiv_v1.mq4 |
//| * |
//| * |
//+------------------------------------------------------------------+
#property copyright "Integer"
#property link "for-good-letters@yandex.ru"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
//---- input parameters
extern int RSIPeriod=14; // ïåðèîä RSI.
extern int RSIPrice=0; // öåíà RSI: 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted.
extern int RSILowerLevel=60; // íèæíèé óðîâåíü RSI, âåðõíèé óðîâåíü îïðåäåëÿåòñÿ êàê 100-RSILowerLevel. Ïîëîæåíèå RSI íèæå íèæíåãî óðîâíÿ ñ÷èòàåòñÿ ìåäâåæüèì òðåíäîì, âûøå âåðõíåãî óðîâíÿ - áû÷üèì.
int RSIUpperLevel;
extern int RSILowerLevel_2=30; // íèæíèé óðîâåíü RSI èñïîëüçóåìûé äëÿ îïðåäåëåíèÿ ïîñëåäíåé çîíû ïåðåêóïëåííîñòè/ïåðåïðîäàííîñòè. Âåðõíèé óðîâåíü îïðåäåëÿåòñÿ êàê 100-RSILowerLevel_2.
int RSIUpperLevel_2;
extern bool CheckLastRSIZone=true; // ïðîâåðÿòü ïîñëåäíþþ çîíó ïåðåêóïëåííîñòè/ïåðåïðîäàííîñòè RSI.
extern bool ReverseRSIZone=false; // ïåðåâîðà÷èâàíèå ïîñëåäíåé çîíû ïåðêóïëåííîñòè/ïåðåïðîäàííîñòè RSI.
extern int CCIPeriod=14; // ïåðèîä CCI
extern int CCIPrice=5; // öåíà CCI: 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted.
extern int CCILevel=200; // âåðõíèé óðîâåíü CCI. Íèæíèé óðîâåíòü ðàâåí - CCILevel.
/*
Ñòðåëêè ðèñóþòñÿ â ñëåäóþùåì ñëó÷àå:
BUY:
RSI âûøå âåðõíåãî óðîâíÿ (îïðåäåëÿåìîãî ïî RSILowerLevel). Ñ íàñòðîéêàìè ïî óìîë÷àíèþ - âûøå 40.
CCI íèæå íèæíåãî óðîâíÿ. Ñ íà÷òðîéêàìè ïî óìîë÷àíèþ - íèæå -200
Åñëè âêëþ÷åíî CheckLastRSIZone, òî ïðîâåðÿåòñÿ ïîñëåäíÿÿ çîíà ïåðêóïëåííîñòè/ïåðåïðîäàííîñòè RSI ïî óðîâíþ (RSILowerLevel_2).
Åñëè ReverseRSIZone=false, äëÿ ïîÿâëåíèÿ ñòðåëêè íåîáõîäèìî, ÷òîáû ïîñëåäíÿÿ çîíà áûëà âûøå âåðõíåãî óðîâíÿ, ñ íàñòðîéêàìè ïî óìîë÷àíèþ - âûøå 70.
Åñëè ReverseRSIZone=true, ïîñëåäíèì çíà÷åíèåì ðñè äîëæíî áûòü çíà÷åíèå íèæå íèæíåãî óðîâíÿ, ñ íàñòðîéêàìè ïî óìîë÷àíèþ - íèæå 30.
*/
//---- buffers
double Buy[];
double Sell[];
double LastRSIZone[];
int Sign=1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(3);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,241);
SetIndexBuffer(0,Buy);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,242);
SetIndexBuffer(1,Sell);
SetIndexBuffer(2,LastRSIZone);
SetIndexLabel(0,"Buy");
SetIndexLabel(1,"Sell");
RSIUpperLevel=100-RSILowerLevel;
RSIUpperLevel_2=100-RSILowerLevel_2;
if(ReverseRSIZone)Sign=-1;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit=Bars-IndicatorCounted();
for(int i=limit-1;i>=0;i--){
LastRSIZone[i]=LastRSIZone[i+1];
double cci=iCCI(NULL,0,CCIPeriod,CCIPrice,i);
double rsi=iRSI(NULL,0,RSIPeriod,RSIPrice,i);
if(rsi>RSIUpperLevel_2){
LastRSIZone[i]=1;
}
if(rsi<RSILowerLevel_2){
LastRSIZone[i]=-1;
}
if(rsi>RSIUpperLevel){
if(cci<-CCILevel){
if(LastRSIZone[i]==Sign || !CheckLastRSIZone)
Buy[i]=Low[i]-Point*5;
}
}
if(rsi<RSILowerLevel){
if(cci>CCILevel){
if(LastRSIZone[i]==-Sign || !CheckLastRSIZone)
Sell[i]=High[i]+Point*5;
}
}
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
Comments