i-PassLevCCI_v.1.3
Download scriptThis script is a specialized trading indicator designed to identify specific momentum shifts in the market using the Commodity Channel Index (CCI). Rather than just looking at a single data point, it analyzes the direction and relative positioning of the CCI to pinpoint high-probability entry and exit points.
Core Trading Logic
The indicator functions by monitoring three distinct types of signals: Buy entries, Sell entries, and Exit points.
1. Buy Signal Logic (Long Positions) The script looks for a specific "recovery" pattern where momentum has dropped significantly but is beginning to turn back upward. For a Buy signal to appear, the following conditions must be met:
- The Threshold: The current CCI value must be above a maximum limit (defaulting to 100).
- The Trend Reversal: It looks back over a set number of bars to find a point where the CCI was previously below the minimum level (defaulting to -100).
- The Confirmation: The script ensures that the momentum has moved from these extreme lows and is showing a consistent upward progression toward the current price.
2. Sell Signal Logic (Short Positions) This follows an inverse logic to the Buy signal, identifying moments where downward pressure is exhausted and beginning to reverse:
- The Threshold: The current CCI value must be below a minimum limit (defaulting to -100).
- The Trend Reversal: It scans backward to confirm that the CCI was previously above the maximum level (100).
- The Confirmation: The indicator verifies that the momentum has transitioned from those extremes and is showing a consistent downward progression toward the current price.
3. Exit Signal Logic The script also includes logic to identify when a trade's momentum has shifted, suggesting it may be time to close a position:
- It monitors whether the CCI has crossed the "zero" line (changing from positive to negative or vice versa).
- If a signal was previously active and the CCI crosses this equilibrium point, an exit marker is placed.
Visual Presentation
To make these signals easy for a trader to read on a chart, the script uses three different types of arrow markers:
- PaleTurquoise Arrows: Represent Buy signals.
- LightSalmon Arrows: Represent Sell signals.
- Red Arrows: Represent Exit points.
Summary for the User
Essentially, this tool filters out "noise" by ignoring minor fluctuations. It only alerts you when the market has moved from an extreme state (overbought or oversold) and shows a distinct directional shift, providing clear visual cues on where to consider entering or exiting a trade based on momentum flow.
//+------------------------------------------------------------------+
//| i-PassLevCCI_v.1.2.mq4 |
//| Èäåÿ Gentor, ðåàëèçàöèÿ â ÌÒ4 KimIV |
//| http://www.kimiv.ru |
//| 23.08.2005 v.1.0 |
//| Ïîñëåäîâàòåëüíûé ïðîõîä ÑÑÈ ÷åðåç óðîâíè -100, 0 è 100 |
//| 24.08.2005 v.1.1 |
//| Èñïðàâëÿþ îøèáêó â àëãîðèòìå. |
//| 25.08.2005 v.1.2 |
//| Èñïðàâèë îøèáêó, íàéäåííóþ extesy. Respect |
//| 26.08.2005 v.1.3 |
//| Îïòèìèçèðîâàí àëãîðèòì. Èñïðàâëåíû áàãè. |
//+------------------------------------------------------------------+
#property copyright "Gentor, KimIV, extesy"
#property link "http://www.kimiv.ru"
//----
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 PaleTurquoise
#property indicator_color2 LightSalmon
#property indicator_color3 Red
//------- Âíåøíèå ïàðàìåòðû ------------------------------------------
extern int CCI_Period =14; // Ïåðèîä CCI
extern int BarsForCheck=9; // Êîëè÷åñòâî áàðîâ äëÿ ïðîâåðêè
extern int MaxLevel =100; // Ìàêñèìàëüíîå çíà÷åíèå óðîâíÿ
extern int MinLevel =-100; // Ìèíèìàëüíîå çíà÷åíèå óðîâíÿ
extern int NumberOfBars=0; // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double SigBuy[];
double SigSell[];
double SigExit[];
//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
bool firstTime=True;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init()
{
SetIndexBuffer(0, SigBuy);
SetIndexStyle (0, DRAW_ARROW);
SetIndexArrow (0, 233);
SetIndexBuffer(1, SigSell);
SetIndexStyle (1, DRAW_ARROW);
SetIndexArrow (1, 234);
SetIndexBuffer(2, SigExit);
SetIndexStyle (2, DRAW_ARROW);
SetIndexArrow (2, 251);
Comment("");
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start()
{
bool fsb=False, fss=False, sig;
double cci0, cci1, cci2, cci3;
int loopbegin, shift, sh, i;
//----
if (firstTime)
{
if (NumberOfBars==0) loopbegin=Bars - 1 - CCI_Period;
else loopbegin=NumberOfBars - 1;
}
if (BarsForCheck<2) BarsForCheck=2;
for(shift=loopbegin; shift>=0; shift--)
{
SigBuy[shift]=EMPTY_VALUE;
SigSell[shift]=EMPTY_VALUE;
SigExit[shift]=EMPTY_VALUE;
cci0=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+1);
sig=False;
// Ñèãíàë íà ïîêóïêó
if (cci0>MaxLevel)
{
for(sh=2; sh<=BarsForCheck; sh++)
{
if (fsb) break;
cci1=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+sh-1);
cci2=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+sh);
if (cci1>cci2)
{
if (cci2<MinLevel)
{
SigBuy[shift]=Low[shift] - 10 * Point;
fsb=True; fss=False; sig=True; break;
}
}
else break;
}
}
// Ñèãíàë íà ïðîäàæó
if (cci0<MinLevel)
{
for(sh=2; sh<=BarsForCheck; sh++)
{
if (fss) break;
cci1=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+sh-1);
cci2=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+sh);
if (cci1<cci2)
{
if (cci2>MaxLevel)
{
SigSell[shift]=High[shift] + 10 * Point;
fss=True; fsb=False; sig=True; break;
}
}
else break;
}
}
// Ñèãíàëû íà âûõîä
cci3=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+2);
if (cci0*cci3<0 && (fsb || fss) && !sig)
{
SigExit[shift]=Close[shift];
fsb=False;
fss=False;
}
}
}
//+------------------------------------------------------------------+
Comments