Author: Dmitry Yakovlev, Russia,Omsk WM R865705290089
gen_RSTL

This script is a technical trading indicator designed to smooth out price action and identify prevailing market trends. It operates by applying a custom mathematical filter to raw price data, effectively reducing "noise" so that the underlying direction of the market becomes clearer to the user.

Core Functionality

1. Data Smoothing (Digital Filtering) The script uses a pre-defined set of numerical coefficients (a "filter") to calculate a smoothed price line. Instead of reacting instantly to every minor fluctuation in price, the logic looks at a sequence of historical data points and combines them into a single weighted value. This helps in creating a continuous flow that represents the broader momentum of the asset.

2. Dynamic Trend Detection Once the price is smoothed, the script analyzes the direction of the resulting line:

  • Upward Movement: If the current smoothed value is higher than the previous one, the script identifies an upward trend.
  • Downward Movement: If the current smoothed value is lower than the previous one, it identifies a downward trend.

3. Visual Representation (The "Up" and "Dn" Lines) To make the data easy to read on a chart, the script separates these trends into two distinct visual components:

  • When the market is moving up, the script draws a line representing the positive momentum (colored Lime).
  • When the market moves down, it switches to drawing a line for negative momentum (colored Red).
  • The logic ensures a clean transition between these states, making it easy for a user to see exactly where a trend shift occurred.

4. Multi-Timeframe Awareness The script is built with flexibility in mind. It allows the user to choose which specific price data points to analyze (such as the Open, High, Low, or Close of a candle). Additionally, it can synchronize the data across different timeframes, ensuring that the smoothed trend remains consistent regardless of the chart's zoom level.

User Experience Features

  • Interaction: The script includes an automated notification system that checks for user engagement and provides a way to support the developer if requested.
  • Clean Visualization: By utilizing different colors and line thicknesses, the indicator is designed to provide immediate visual feedback, allowing traders to distinguish between "buying" zones and "selling" zones at a glance.
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
10 Views
0 Downloads
0 Favorites
gen_RSTL
// -----------------------------------------------------------------
//  RSTL
//  Dmitry Yakovlev 
//  dmitry_yakovlev@rambler.ru
//  WebMoney R865705290089
//------------------------------------------------------------------
// Parameters DF:
// P1=52, D1=32, A1=40, P2=52, D2=32, A2=40, Ripple=0.08, Delay=15


#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.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 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("RSTL-"+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-1)/koef+1;
      //-------------------------------
      while(i>=0)
      {
         res=0;
         for (j=0; j<FilterSize; j++)
            res+=F[j]*price(i+j);
         
         nn=i*koef;
         if(nn!=-1) iBuffer[nn]=NormalizeDouble(res,Digits);
         
         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,Digits);
         }
         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,"Åñëè Âàì ïîíðàâèëñÿ èíäèêàòîð RSTL,\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