2ZZ+Signal_
Download scriptThis script is designed as a specialized technical analysis tool for the MetaTrader platform. Its primary purpose is to identify specific market trends and generate visual "Buy" and "Sell" signals by combining multiple data streams.
Core Logic and Methodology
The tool operates by layering three distinct types of information to filter out market "noise" and provide clearer trading directions:
1. Trend Identification (ZZS Integration) The script pulls data from an external component called "ZZS." It monitors two specific depths—Bullish and Bearish—to determine the prevailing momentum of the market. By tracking how these levels move, the tool can distinguish between a temporary price fluctuation and a meaningful shift in trend direction.
2. Momentum Filtering (SSRC) To ensure the signals are high-quality, the script uses a secondary filter called "SSRC" (Snake Range). This acts as a secondary "opinion" on the market. The logic requires that the primary trend identified by the ZZS component aligns with the momentum confirmed by the SSRC before any visual signal is displayed.
3. Dynamic Price Sensitivity The script includes an automated scaling mechanism based on the timeframe you are viewing (e.g., 5-minute, 1-hour, or Daily charts). It calculates a "distance" factor automatically; this ensures that the distance between the price and the trend line is proportional to the volatility of that specific timeframe.
How Signals Are Generated
The indicator looks for a specific "confluence" of events to trigger an alert on your chart:
- For Sell Signals: The tool looks for a bearish trend, combined with a specific downward momentum from the filter, where the price closes significantly below a calculated threshold and shows a downward movement in the current candle.
- For Buy Signals: Conversely, it looks for a bullish trend, upward momentum, and a price close significantly above a calculated threshold with an upward movement in the current candle.
Visual Feedback and Notifications
The script provides several layers of visual feedback for the user:
- Trend Lines: It draws lines on the chart to represent the active boundaries of the market movement.
- Directional Arrows: Specific icons appear on the chart to mark exact entry points where both the trend and momentum conditions have been met.
- Dynamic Comments: The script provides real-time text updates on the chart screen. These comments inform you of the current price levels relative to the signals and provide warnings regarding risk management.
In summary, this tool acts as a "double-check" system: it waits for the primary trend to move, verifies that the momentum is moving in the same direction, and then paints a signal on your chart only when all conditions align perfectly.
//+------------------------------------------------------------------+
//| 2ZZ+Signal.mq4 |
//| Copyright © 2008, HomeSoft-Tartan Corp. |
//| spiky@transkeino.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, HomeSoft-Tartan Corp."
#property link "spiky@transkeino.ru"
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Magenta
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Aqua
#property indicator_color6 Gold
//---- indicator parameters
extern int SnakeRange = 3;
extern int FilterPeriod = 21;
extern double MartFiltr = 2.0;
extern int PriceConst = 6;
//+------------------------------------------------------------------+
extern string ZZ="ZZS";
extern int LDepth=20;
extern int BDepth=30;
extern int Deviation=5;
extern int Backstep=3;
extern int kb=1;
extern int nBars=500;
double BZZBuff[],LZZBuff[],StartBuff[],StopBuff[],UpBuff[],DnBuff[],ssrone,ssrnul,bzz,lzz,ibzz,ilzz,bbzz,llzz,zz,zzold,sd,zzb,lzold;
int shift,zzbar,i,fs,fb,pr,k,ns,nb,bbar;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,BZZBuff);
SetIndexBuffer(1,LZZBuff);
SetIndexBuffer(2,StartBuff);
SetIndexBuffer(3,StopBuff);
SetIndexBuffer(4,UpBuff);
SetIndexBuffer(5,DnBuff);
SetIndexStyle(0,DRAW_SECTION,EMPTY,2,Magenta);
SetIndexStyle(1,DRAW_SECTION,STYLE_DOT,0,Red);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID,2,Lime);
SetIndexStyle(3, DRAW_LINE, STYLE_SOLID,2,Red);
SetIndexStyle(4,DRAW_ARROW,EMPTY,1);
SetIndexArrow(4,241);
SetIndexStyle(5,DRAW_ARROW,EMPTY,1);
SetIndexArrow(5,242);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);
SetIndexEmptyValue(3,0.0);
SetIndexEmptyValue(4,0.0);
SetIndexEmptyValue(5,0.0);
if (Period()==5) sd=1;
if (Period()==15) sd=3;
if (Period()==30) sd=5;
if (Period()==60) sd=10;
if (Period()==240) sd=15;
if (Period()==1440) sd=20;
if (Period()>1440) sd=25;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
if (Period()<5) {Comment("\n"," Ðàáîòàòü ìîæíî íà ÒÔ=M5 è âûøå. Ñìåíèòå ÒÔ!");return(0);}
for (shift=nBars;shift>=0;shift--)
{
if (bzz!=0 && lzz!=0 && bzz!=zzold && lzz!=zzold && bzz==lzz) zzold=bzz;
bzz=iCustom(NULL,0,ZZ,BDepth,Deviation,Backstep,nBars,0,shift+1);
bbzz=iCustom(NULL,0,ZZ,BDepth,Deviation,Backstep,nBars,0,shift);
BZZBuff[shift]=bbzz;
if (lzz!=0 && lzold!=lzz) lzold=lzz;
lzz=iCustom(NULL,0,ZZ,LDepth,Deviation,Backstep,nBars,0,shift+1);
llzz=iCustom(NULL,0,ZZ,LDepth,Deviation,Backstep,nBars,0,shift);
LZZBuff[shift]=llzz;
ssrone=iCustom(NULL,0,"SSRC",SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,shift+1);
ssrnul=iCustom(NULL,0,"SSRC",SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,shift);
for (i=1;i<nBars;i++)
{
zzb=iCustom(NULL,0,ZZ,BDepth,Deviation,Backstep,nBars,0,i);
if (zzb!=0) {bbar=i;break;}
}
if (bzz!=0 && lzz!=0) k=0;
if (k==0)
{ k=1;
if (bzz!=zzold && zzold>bzz) {fb=1;fs=0;nb=0;zzbar=shift+1;}
if (bzz!=zzold && zzold<bzz) {fs=1;fb=0;ns=0;zzbar=shift+1;}
}
if (fs==1 && ssrone>ssrnul && ssrone>0 && ns==0 && bbar>=kb && Close[shift]<=zzold-3*sd*Point && Close[shift]<Open[shift])
{
ns=1;DnBuff[shift]=High[shift]+2*sd*Point; if (DnBuff[shift+1]!=0) DnBuff[shift+1]=0;
}
if (fb==1 && ssrone<ssrnul && ssrone<0 && nb==0 && bbar>=kb && Close[shift]>=zzold+3*sd*Point && Close[shift]>Open[shift])
{
nb=1;UpBuff[shift]=Low[shift]-2*sd*Point; if (UpBuff[shift+1]!=0) UpBuff[shift+1]=0;
}
if (fb==1 && k==1 && lzold==zzold)
{
for (i=zzbar;i>=zzbar-10;i--)
{
if (i>3) {StartBuff[i+1]=zzold+3*sd*Point;StopBuff[i+1]=zzold-sd*Point;}
}
Comment("\n"," Ïîêóïàé ïî ñèãíàëó ïðè öåíå îò ",zzb+3*sd*Point," ïîñëå çàêðûòèÿ áàðà");
StopBuff[i]=0;StartBuff[i]=0;
}
if (fs==1 && k==1 && lzold==zzold)
{
for (i=zzbar;i>=zzbar-10;i--)
{
if (i>3) {StartBuff[i+1]=zzold-3*sd*Point;StopBuff[i+1]=zzold+sd*Point;}//zzold-zzb
}
Comment("\n"," Ïðîäàâàé ïî ñèãíàëó ïðè öåíå îò ",zzb-3*sd*Point," ïîñäå çàêðûòèÿ áàðà");
StopBuff[i]=0;StartBuff[i]=0;
}
for (i=zzbar+1;i<zzbar+nBars;i++) {StartBuff[i]=0;StopBuff[i]=0;} //????
if ((fb==1 && Ask>zzold+3*sd*Point && ssrone<=ssrnul && ssrnul>0) || (fs==1 && Bid<zzold-3*sd*Point && ssrone>=ssrnul && ssrnul<0))
{
Comment("\n"," Ìîæåøü òîðãîâàòü íà ñâîé ñòðàõ è ðèñê! Íî!!!",
"\n"," Ïðîäàæà âîçìîæíà=",fs," Ïîêóïêà âîçìîæíà=",fb);StopBuff[i]=0;StartBuff[i]=0;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments