gen_fatl
Download scriptOverview of the FATL Indicator Logic
The FATL script is a specialized technical analysis tool designed to identify market trends by applying a mathematical "Digital Filter" to price data. Unlike standard moving averages that might simply average out recent prices, this script uses a specific weighted calculation to smooth out market noise and highlight the underlying direction of the asset.
Core Functional Logic
1. Data Input Selection The tool is versatile in how it perceives market movement. It allows you to choose which specific price point to analyze from each candle:
- Close Price: The standard final price of a period (Default).
- Open Price: The starting price of a period.
- High/Low Prices: The extreme limits reached during a period.
2. The Digital Filter Calculation The heart of the script is a pre-defined set of "weights" (coefficients). The logic takes these weights and multiplies them against historical price data. This creates a smoothed trend line where certain historical points are given more significance than others.
3. Multi-Timeframe Alignment The script contains logic to handle different timeframes. It can synchronize data so that even if you are looking at a smaller chart, it can calculate values based on larger time intervals, ensuring the "Filtered" line remains consistent across your various views.
4. Trend Identification and Visualization Once the filtered price is calculated, the script performs two primary actions:
- Directional Analysis: It compares the current filtered value against the previous one. If the value is increasing, it identifies an upward trend; if decreasing, a downward trend.
- Visual Signaling: The tool splits these trends into two distinct visual components:
- Up Trend: When the filter confirms positive momentum, a specific line (colored Lime) is drawn.
- Down Trend: When the filter confirms negative momentum, a different line (colored Red) is drawn.
Summary of User Experience
For the end user, this logic translates into a visual "path" on the chart. Instead of seeing volatile price spikes, the indicator provides a clear, smoothed trajectory. By looking at where the Lime and Red lines appear, you can identify the predominant direction of the market as filtered through the author's specific mathematical model.
Administrative Features
The script also includes a built-in verification system to manage user interactions. It checks for a local record to determine if a notification has been shown recently, ensuring that the "support the author" prompt appears only once every five days, providing a non-intrusive experience for the trader.
//------------------------------------------------------------------
// FATL
// Dmitry Yakovlev
// dmitry_yakovlev@rambler.ru
// WebMoney R865705290089
//------------------------------------------------------------------
// --- Parameters DF:
// FATL: P1=14, D1=10, A1=40, P2=41, D2=31, A2=10, Ripple=0.0864, Delay=0
#property copyright "Dmitry Yakovlev, Russia,Omsk WM R865705290089"
#property link "dmitry_yakovlev@rambler.ru"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Black
#property indicator_color2 Lime
#property indicator_color3 Red
#property indicator_width1 0
#property indicator_width2 2
#property indicator_width3 2
#import "shell32.dll" //Connect a dll (provided with Windows)
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import "user32.dll"
int MessageBoxA(int hWnd ,string lpText,string lpCaption,int uType);
//------------------------------------------------------------------------------------------------------
// ÏÀÐÀÌÅÒÐÛ
extern string _tf="Òàéìôðåéì (0-òåêóùèé)";
extern int tf=0;
extern string _pr="Öåíà 0-cl,1-op,2-hi,3-lo";
extern int pr=0;
extern string _donate1="Äëÿ $ áëàãîäàðíîñòè:";
extern string _donate2="R865705290089";
//---- buffers
double iBuffer[];
double up[];
double dn[];
double trend[];
double F[]=
{
0.342152940854,+0.3093292710818,+0.2494886026077,+0.1729967470992,+0.0925637619799,+0.02063133334364,-0.0330807757871,
-0.0633224564657,-0.0699201252728,-0.0571825815615,-0.0326138365275,-0.00472222203391,+0.01887417755416,+0.0330626229331,
+0.0359799385551,+0.02892153255004,+0.01547756053013,+0.0002774619935816,-0.01239612720349,-0.01962143471368,
-0.02040646532991,-0.01564282987562,-0.00754279142733,+0.001162950482821,+0.00803410120806,+0.01154650780504,
+0.01135097902722,+0.00815882017765,+0.00337147099221,-0.001454786740187,-0.00509465397315,-0.00705602263847,
-0.00791744078702,-0.00996601702916,+0.00455978659094
};
int FilterSize=0;
//+------------------------------------------------------------------+
//| Digital filter indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
CheckDonate();
FilterSize=ArraySize(F);
if(tf<Period()) tf=Period();
if(pr>1)pr=0;
//---- indicator line
IndicatorShortName("FATL-"+tf);
IndicatorBuffers(4);
//---- indicator line
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(0,iBuffer);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(1,up);
SetIndexLabel(1,"Up");
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(2,dn);
SetIndexLabel(2,"Dn");
SetIndexStyle(3,DRAW_NONE);
SetIndexBuffer(3,trend);
SetIndexLabel(3,"trend");
ArraySetAsSeries(iBuffer, true);
ArraySetAsSeries(trend, true);
//----
return(0);
}
//+------------------------------------------------------------------+
double price(int i)
{
if(pr==0) return(iClose(Symbol(),tf,i));
else if(pr==1) return(iOpen(Symbol(),tf,i));
else if(pr==2) return(iHigh(Symbol(),tf,i));
else if(pr==3) return(iLow(Symbol(),tf,i));
}
//+------------------------------------------------------------------+
int start()
{
int k, nn, nn1, i, j, counted_bars=IndicatorCounted();
int koef=(tf/Period());
double res=0, step=0;
// <--- ðàñ÷èòûâàåì çíà÷åíèÿ èíäèêàòîðà
if (FilterSize>0)
{
if(Bars<=FilterSize) return(0);
//-------------------------------
i=(Bars-counted_bars+FilterSize)/koef+1;
//-------------------------------
while(i>=0)
{
res=0;
for (j=0; j<FilterSize; j++)
res+=F[j]*price(i+j);
nn=i*koef;
iBuffer[nn]=res;//NormalizeDouble(res,Digits);
nn1=(i+1)*koef;
if(iBuffer[nn1]!=EMPTY_VALUE && iBuffer[nn1]!=0)
{
step=(iBuffer[nn1]-iBuffer[nn])/koef;
for(k=1;k<koef;k++) iBuffer[k+nn]=iBuffer[nn]+step*k;
}
i--;
}
} else return;
// ðàñ÷èòûâàåì -->
//-------------------------------------------------------------------------
// <-- ðàñêðàøèâàåì
for(int x=Bars;x>=0;x--)
{
trend[x] = trend[x+1];
if (iBuffer[x]> iBuffer[x+1]) trend[x] =1;
if (iBuffer[x]< iBuffer[x+1]) trend[x] =-1;
if (trend[x]>0)
{ up[x] = iBuffer[x];
if (trend[x+1]<0) up[x+1]=iBuffer[x+1];
dn[x] = EMPTY_VALUE;
}
else
if (trend[x]<0)
{
dn[x] = iBuffer[x];
if (trend[x+1]>0) dn[x+1]=iBuffer[x+1];
up[x] = EMPTY_VALUE;
}
}
// ðàñêðàøèâàåì -->
//-------------------------------------------------------------------------
return(0);
}
void CheckDonate()
{
int fd=0; string pay="0"; datetime dt=0;
string fn="DigFlts1.txt";
fd=FileOpen(fn,FILE_READ|FILE_CSV,";");
if(fd>=1)
{
pay=FileReadString(fd); if(pay!="0" && pay!="1") pay="0";
dt=StrToTime(FileReadString(fd));
}
else
{
dt=TimeCurrent();
fd=FileOpen(fn,FILE_WRITE|FILE_CSV,";");
FileWrite(fd,"0",TimeToStr(dt,TIME_DATE));
}
FileClose(fd);
if(pay=="0" && (TimeCurrent()-dt)>10*24*60*60) // 5 äíåé
{
if(MessageBoxA(0,"Åñëè Âàì ïîíðàâèëñÿ èíäèêàòîð FATL,\n õîòèòå ïîìî÷ü àâòîðó ìàòåðèàëüíî?","Âîïðîñ",4)==6)
{
ShellExecuteA(0,"Open","iexplore.exe","wmk:payto?Purse=R865705290089&Amount=100&Desc=DigitalIndicators&BringToFront=Y&ExecEvenKeeperIsOffline=Y","",7);
pay="1";
}
dt=TimeCurrent();
fd=FileOpen(fn,FILE_WRITE|FILE_CSV,";");
FileWrite(fd,pay,TimeToStr(dt,TIME_DATE));
FileClose(fd);
}
FileClose(fd);
}
Comments