_Channel@Aroon
Download scriptThis custom technical indicator is designed to identify key price structural points—specifically market peaks and valleys (troughs)—while filtering out "noise" by utilizing a secondary momentum logic. It combines classic price action geometry with the Aroon indicator to provide a cleaner view of market trends than standard volatility-based tools.
Core Logic and Functionality
1. Momentum Filtering (The Aroon Engine) Instead of identifying every small wiggle in the price, the script relies on the Aroon Indicator. This logic looks at how long it has been since the price reached a new high or low over a specific period. The script specifically monitors for "extreme" signals:
- It flags a potential trend shift when the Aroon "Up" line reaches its maximum value while the "Down" line remains below a user-defined threshold.
- Conversely, it looks for the "Down" line hitting its maximum while the "Up" line is suppressed. This ensures that the indicator only reacts to significant momentum shifts rather than minor price fluctuations.
2. Dynamic Peak and Trough Identification Once a momentum shift is detected via the Aroon logic, the script enters a "search mode" to locate the exact geometric peak or valley:
- Peak Detection: When the downward momentum is confirmed, the script scans back through recent history to find the highest price point reached during that move.
- Trough Detection: When upward momentum is confirmed, it scans back to identify the lowest price point from which the current move originated.
3. Visual Representation Modes The script offers three distinct ways to visualize these identified points based on user preference:
- ZigZag Mode: This draws a continuous connected line between the peaks and troughs, highlighting the "skeleton" of the market movement.
- Time-Based Channeling: Instead of just marking the point of the peak, this mode can project lines to show the duration or the specific boundary of the price move.
- Dynamic Channels: The script can plot upper and lower boundaries (Top and Bottom channels) that track the most recent confirmed extremes, helping traders visualize the current "trading range."
Summary for the Trader
Think of this tool as a filter. While the market is constantly moving, this script ignores the "middle" movements and focuses exclusively on the structural turning points. By combining the Aroon Indicator (which measures trend strength) with Price Action (which identifies actual highs and lows), it provides a visual map of where the market has successfully turned, allowing for a clearer understanding of historical price structure and current trend direction.
#property indicator_chart_window // â îêíå èíñòðóìåíòà
#property indicator_buffers 6
#property indicator_color1 Magenta // çèãçàã
#property indicator_color3 Green // âåðõí. ãð. êàíàëà
#property indicator_color4 Red // íèæí. ãð. êàíàëà
// âõîäíûå ïàðàìåòðû
extern int CheckLevel=100; // óðîâåíü ïðîòèâîïîëîæíîãî ñèãíàëà Aroon
extern int AroonPeriod=14; // Ïåðèîä Aroon
extern int ShowChannel=2; // ïîêàçàòü 1 - ïî ìåñòó ýêñòðåìóìîâ, 2 - ïî âðåìåíè îïðåäåëåíèÿ
extern int ShowZigZag=0; // ïîêàçàòü 1 - ïî ìåñòó ýêñòðåìóìîâ, 2 - ïî âðåìåíè îïðåäåëåíèÿ
// èíä.áóôåðû
double ZZpeak[], // ïèê
ZZtrough[], // âïàäèíà
ChTop[], // âåðõí. ãð. êàíàëà
ChBot[], // íèæí. ãð. êàíàëà
AroonUp[], // AroonUp
AroonDn[]; // AroonDn
// îáùèå ïåðåìåííûå
double OverBought; // çîíà ïåðåêóïëåííîñòè
bool dir; // 0-ïîéìàíà âïàäèíà, 1 - ïèê
double max,min; // òåêóùèå ìàêñ., ìèíèìóìû
double top,bot; // ïèêè, âïàäèíû
int jDn,jUp; // ñ÷åò÷èêè ðàññòîÿíèÿ ìåæäó ýêñòðåìóìàìè
bool count=1; // íàïðàâëåíèå ïîèñêà öåíîâîãî ýêñòðåìóìà; 1 - îò ñòàðøèõ áàðîâ ê ìëàäøèì
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
if(ShowZigZag<0 || ShowChannel<0) count=0;
ShowZigZag=MathAbs(ShowZigZag); ShowChannel=MathAbs(ShowChannel);
//---- indicators
SetIndexBuffer(0,ZZpeak);
SetIndexEmptyValue(0,0.0);
SetIndexLabel(0,"Peak");
SetIndexBuffer(1,ZZtrough);
SetIndexEmptyValue(1,0.0);
SetIndexLabel(1,"Trough");
if(ShowZigZag>0) {
SetIndexStyle(0,DRAW_ZIGZAG);
SetIndexStyle(1,DRAW_ZIGZAG);
}
else {
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_NONE);
}
SetIndexBuffer(2,ChTop);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(2,DRAW_LINE);
SetIndexLabel(2,"ChTop");
SetIndexBuffer(3,ChBot);
SetIndexEmptyValue(3,0.0);
SetIndexStyle(3,DRAW_LINE);
SetIndexLabel(3,"ChBot");
if(ShowChannel>0) {
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
}
else {
SetIndexStyle(2,DRAW_NONE);
SetIndexStyle(3,DRAW_NONE);
}
SetIndexBuffer(4,AroonUp);
SetIndexStyle(4,DRAW_NONE);
SetIndexBuffer(5,AroonDn);
SetIndexStyle(5,DRAW_NONE);
string _up="Up("+AroonPeriod+")"+CheckLevel;
SetIndexLabel(4,_up);
string _dn="Dn("+AroonPeriod+")"+CheckLevel;
SetIndexLabel(5,_dn);
//----
IndicatorShortName("ZZ@Aroon");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int ic=IndicatorCounted();
if(Bars-ic-1>1) ic=reinit();
int limit=Bars-ic-1; // êîë-âî ïåðåñ÷åòîâ
for(int i=limit; i>=0; i--) {
AroonUp[i]=iCustom(NULL,0,"Aroon_Up_Down",AroonPeriod, 0,i);
AroonDn[i]=iCustom(NULL,0,"Aroon_Up_Down",AroonPeriod, 1,i);
}
for(i=limit; i>0; i--)
{
bool up=AroonUp[i]==100 && AroonDn[i]<CheckLevel; // íà÷àëî àïòðåíäà
bool dn=AroonUp[i]<CheckLevel && AroonDn[i]==100; // íà÷àëî äàóíòðåíäà
jDn++; jUp++; // ñ÷åò÷èêè ðàññòîÿíèÿ ìåæäó ýêñòðåìóìàìè
if(dir) { // ëîâèòñÿ âïàäèíà
if(up) { // åñëè â çîíå ÏÊ, òî
double l=High[i]*100;
if(count) {for(int k=jUp; k>=0; k--) if(Low[i+k]<l) {int sh=i+k;l=Low[i+k];}}
else {for(k=0; k<=jUp; k++) if(Low[i+k]<l) {sh=i+k;l=Low[i+k];}}
bot=Low[sh]; // âïàäèíà = ìèíèìóìó
if(ShowZigZag==1) ZZtrough[sh]=bot; else ZZtrough[i]=bot;
if(ShowChannel==1) for(k=sh; k>i; k--) ChBot[k]=bot;
dir=0; // ïîéìàíà âïàäèíà öåíû
}
}
else { // ëîâèòñÿ ïèê
if(dn) { // åñëè â çîíå ÏÏ, òî
double h=0;
if(count) {for(k=jDn; k>=0; k--) if(High[i+k]>h) {sh=i+k; h=High[i+k];}}
else {for(k=0; k<=jDn; k++) if(High[i+k]>h) {sh=i+k; h=High[i+k];}}
top=High[sh];
if(ShowZigZag==1) ZZpeak[sh]=top; else ZZpeak[i]=top;
if(ShowChannel==1) for(k=sh; k>i; k--) ChTop[k]=top;
dir=1; // ïîéìàí ïèê öåíû
}
}
if(up) jUp=-2; if(dn) jDn=-2; // ñáðîñ ñ÷åò÷èêîâ
for(k=0; k<2; k++) {ChTop[i-k]=top; ChBot[i-k]=bot;}
}
return(0);
}
// ô-ÿ äîïîëíèòåëüíîé èíèöèàëèçàöèè
int reinit()
{
ArrayInitialize(ZZpeak,0.0);
ArrayInitialize(ZZtrough,0.0);
ArrayInitialize(ChTop,0.0);
ArrayInitialize(ChBot,0.0);
ArrayInitialize(AroonUp,0.0);
ArrayInitialize(AroonDn,0.0);
dir=0;max=0;min=0;top=0;bot=0;jDn=0;jUp=0;
return(0);
}
Comments