Author: Dmitry Yakovlev, Russia,Omsk WM R865705290089
gen_STLM

This script functions as a custom technical analysis indicator designed for the MetaTrader trading platform. It processes historical price data to generate a visual signal, which is displayed in a separate window below the main price chart.

Core Logic and Functionality

The indicator operates by applying two distinct mathematical filters to market price data. It utilizes predefined sets of coefficients (weighting factors) to calculate a specific value for every point in time on the chart.

1. Data Input Selection The script allows users to choose which type of price information it should analyze from the current timeframe. It can be configured to look at:

  • Closing prices
  • Opening prices
  • High prices
  • Low prices

2. Multi-Timeframe Analysis A key feature of this logic is its ability to reference different timeframes. If a user specifies a higher timeframe (for example, looking at hourly data while viewing a 15-minute chart), the script calculates a "coefficient" to ensure the data aligns correctly across the bars on the screen.

3. Filtering Mechanism The heart of the indicator lies in two mathematical filters (F1 and F2). The script:

  • Applies the first filter to the price data to produce one result.
  • Applies the second filter to the price data to produce a second result.
  • Calculates the difference between these two results.

By subtracting the second filtered value from the first, the indicator highlights specific movements or trends in the market, effectively smoothing out "noise" while identifying underlying momentum.

4. Visual Smoothing and Interpolation Because the script can calculate data for higher timeframes than what is currently visible on the screen, it includes an interpolation logic. If there are gaps between the calculated data points, the script automatically fills those gaps with a linear progression. This ensures that the resulting line appears smooth and continuous to the user rather than appearing as disconnected dots.

Administrative Features

In addition to its mathematical calculations, the script contains a built-in management system:

  • License/Donation Check: The script includes a routine that checks a local file to see if it has been "activated."
  • User Interaction: If the script detects it hasn't been activated within a specific timeframe (10 days), it is designed to display a pop-up message box asking the user for support.
  • External Connection: If the user interacts with this prompt, the script has the capability to open a web browser automatically to a specific payment gateway.
Price Data Components
Series array that contains close prices for each barSeries array that contains open prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
Implements a curve of type %1Uses files from the file systemIt reads information from a fileIt writes information to file
16 Views
0 Downloads
0 Favorites
gen_STLM
// -----------------------------------------------------------------
//  STLM
//  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[];

// satl
double F1[]=
{
0.0972300859804,+0.0968062969346,+0.0955419164365,+0.0934577611122,+0.0905880510165,+0.0869797096772,+0.0826914069223,
+0.0777923665825,+0.0723609665321,+0.0664831632194,+0.0602507767255,+0.0537596753828,+0.0471079009917,+0.0403937766681,
+0.0337140392862,+0.02716203738993,+0.02082603334880,+0.01478764551201,+0.00912046226174,+0.00388885529508,-0.000852985685581,
-0.00506178027993,-0.00870563597026,-0.01176427325104,-0.01422899856638,-0.01610243213838,-0.01739800330289,-0.01813923109192,
-0.01835881240394,-0.01809754409022,-0.01740310857099,-0.01632875511194,-0.01493191058141,-0.01327275433432,
-0.01141279180993,-0.00941346048840,-0.00733480005313,-0.00523421600395,-0.00316536264050,-0.001177167392015,
+0.000686985962009,+0.002389902406856,+0.00390104132106,+0.00519679976189,+0.00626061537269,+0.00708289540657,
+0.00766078247257,+0.00799777120465,+0.00810319306032,+0.00799158883572,+0.00768199022585,+0.00719713287712,
+0.00656262390426,+0.00580608681889,+0.00495630628786,+0.00404239415109,+0.003092996720318,+0.002135561583368,
+0.001195679980891,+0.0002965183278544,-0.000541650350472,-0.001301807370162,-0.001970437316184,-0.002537663958766,
-0.002997275636143,-0.00334664596644,-0.00358655892238,-0.00372095011838,-0.00375657848736,-0.00370264425443,
-0.00357037017995,-0.00337256344445,-0.003123175378339,-0.002836875741331,-0.002528657914549,-0.002213492109737,
-0.001906047326282,-0.001620512609322,-0.001370567038003,-0.001169534616626,-0.001029918389440,-0.000935870061783,+0.01034202700017
};
// rstl
double F2[]=
{
0.01341275670244,+0.01664816964612,+0.01994665904343,+0.02326212889313,+0.02654681001870,+0.02975214994927,+0.0328297351288,
+0.0357322252715,+0.0384142791389,+0.0408334509856,+0.0429510374057,+0.0447328553079,+0.0461499332233,+0.0471791000672,
+0.0478034577969,+0.0480127270532,+0.0478034577969,+0.0471791000672,+0.0461499332233,+0.0447328553079,+0.0429510374057,
+0.0408334509856,+0.0384142791389,+0.0357322252715,+0.0328297351288,+0.02975214994927,+0.02654681001870,+0.02326212889313,
+0.01994665904343,+0.01664816964612,+0.01341275670244,+0.01028400463391,+0.00730221700998,+0.00450373216023,+0.001920337166728,
-0.000421208810927,-0.002499533683769,-0.00429888875907,-0.00580925991051,-0.00702635421454,-0.00795146555058,-0.00859122539521,
-0.00895724756993,-0.00906567797492,-0.00893666230957,-0.00859374640340,-0.00806322502345,-0.00737345585885,-0.00655415579111,
-0.00563569652912,-0.00464841622322,-0.00362196278436,-0.002584683349824,-0.001563072694533,-0.000581291439979,+0.000339237275693,
+0.001180146358890,+0.001926354690352,+0.002566207013007,+0.003091524748164,+0.00349757094703,+0.00378293461495,
+0.00394934142052,+0.00400139928647,+0.00394628853428,+0.00379340711489,+0.00355398200990,+0.00324065814703,+0.002867076161374,
+0.002447450072594,+0.001996155460121,+0.001527338023121,+0.001054551524600,+0.000590433053583,+0.0001464223074371,
-0.0002674697874970,-0.000642839315725,-0.000973012294327,-0.001253111789180,-0.001480070449084,-0.001652591352877,
-0.001771061630403,-0.001837424708730,-0.001855018184432,-0.001828385176982,-0.001763067544375,-0.001665389539620,-0.001542240402933,
-0.001400864138698,-0.001248664557252,-0.001093034027767,-0.000941216179175,-0.000800217636477,-0.000676793200790,-0.000577522335408,
-0.000508579109241,-0.000462137551156,+0.00510694724302
};

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("STLM-"+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,"Åñëè Âàì ïîíðàâèëñÿ èíäèêàòîð STLM,\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