gen_FTLM
Download scriptThis script is a custom technical analysis indicator designed for the MetaTrader platform. Its primary purpose is to generate a visual signal on a chart by calculating the relationship between two distinct mathematical filters based on historical price data.
Core Functionality
Price Data Selection The indicator allows the user to choose which specific price points from the market are used for its calculations. You can configure it to look at:
- Closing Prices (Default)
- Opening Prices
- High Prices
- Low Prices
Mathematical Filtering The script utilizes two unique sets of pre-defined coefficients (weighted values). It processes these weights against historical price data to create two separate result values. By subtracting one result from the other, it produces a final "net" value. This logic is designed to highlight trends or momentum by filtering out market noise.
Timeframe Adaptation The logic includes an automated adjustment feature. If you apply the indicator to a timeframe smaller than the one it was originally optimized for, the script automatically calculates a "coefficient." It uses this to scale and smooth the data appropriately, ensuring that the visual output remains consistent across different timeframes.
Visual Output and Smoothing The final result is displayed as a line on a separate window below the main price chart. To ensure the line appears fluid rather than jagged, the script includes a "step" calculation. This fills in any gaps between data points by interpolating the values, creating a continuous and smooth visual representation of the underlying mathematical trend.
Administrative Features
- Notification System: The script includes a built-in check that periodically prompts the user with a message regarding the author's work.
- Data Logging: It maintains a small local file to track how often these prompts appear, ensuring they do not interrupt the user's experience too frequently (e.g., limiting the frequency of requests).
// -----------------------------------------------------------------
// FTLM
// Dmitry Yakovlev
// dmitry_yakovlev@rambler.ru
// WebMoney R865705290089
//------------------------------------------------------------------
#property copyright "Dmitry Yakovlev, Russia,Omsk WM R865705290089"
#property link "dmitry_yakovlev@rambler.ru"
//-------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_level1 0
#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[];
// fatl
double F1[]=
{
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
};
// rftl
double F2[]=
{
0.0427244051220,+0.0798496403966,+0.1151557791422,+0.1427762745496,+0.1579266069793,+0.1579266069793,+0.1427762745496,
+0.1151557791422,+0.0798496403966,+0.0427244051220,+0.00952274869912,-0.01526900415719,-0.02922757486830,-0.0322728430050,
-0.02639360942444,-0.01505348026677,-0.002179623244963,+0.00871170305657,+0.01526062539351,+0.01660716287034,
+0.01334923351197,+0.00714393572868,+0.0001280673815127,-0.00572164688704,-0.00905661252147,-0.00941895697856,
-0.00722021865323,-0.00348150582689,+0.000536779907191,+0.00370827835280,+0.00532949036053,+0.00523924067169,
+0.00376584455008,+0.001556160742037,-0.000671481978740,-0.002351525647288,-0.00325682927431,-0.00365443171797,
-0.00459998751022,+0.002104648357131
};
int FilterSize1=0, FilterSize2=0;
//+------------------------------------------------------------------+
int init()
{
CheckDonate();
FilterSize1=ArraySize(F1);
FilterSize2=ArraySize(F2);
if(tf<Period()) tf=Period();
if(pr>1)pr=0;
//---- indicator line
IndicatorShortName("FTLM-"+tf);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,iBuffer);
//----
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 res1=0, res2=0, step=0;
// <--- ðàñ÷èòûâàåì çíà÷åíèÿ èíäèêàòîðà
if(FilterSize1>0 && FilterSize2>0)
{
if(Bars<=FilterSize1) return(0);
if(Bars<=FilterSize2) return(0);
//-------------------------------
i=(Bars+FilterSize2-counted_bars)/koef+1;
//-------------------------------
while(i>=0)
{
res1=0; for (j=0; j<FilterSize1; j++) res1+=F1[j]*price(i+j);
res2=0; for (j=0; j<FilterSize2; j++) res2+=F2[j]*price(i+j);
nn=i*koef;
if(nn!=-1) iBuffer[nn]=res1/Point-res2/Point;
nn1=(i+1)*koef;
if(nn!=-1 && nn1!=-1 && iBuffer[nn1]!=EMPTY_VALUE && iBuffer[nn1]!=0)
{
step=(iBuffer[nn1]-iBuffer[nn])/koef;
for(k=1;k<koef;k++) iBuffer[k+nn]=NormalizeDouble(iBuffer[nn]+step*k,0);
}
i--;
}
} else return;
// ðàñ÷èòûâàåì -->
//-------------------------------------------------------------------------
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,"Åñëè Âàì ïîíðàâèëñÿ èíäèêàòîð FTLM,\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