TickAdaptiveRSI_v1

Download script
Author: Copyright � 2008, TrendLaboratory
TickAdaptiveRSI_v1

Technical Logic Overview: TickAdaptiveRSI

This script is designed to provide a high-precision, real-time analysis of market momentum by focusing on "ticks"—the smallest individual price movements—rather than just the standard candles (OHLC) used by most traders. By analyzing these rapid fluctuations, the tool attempts to provide a smoother and more responsive view of price action.

Core Methodology

The script functions by calculating a specialized movement value based on the Adaptive RSI (Relative Strength Index). Instead of looking at simple price changes over a set period, it interprets the volatility of the Adaptive RSI itself to determine the "Tick" value.

This process involves several layers of data processing:

  • Dynamic Tick Tracking: The script monitors the most recent price movements and converts the change in the Adaptive RSI into a numerical "Tick" value. This allows the indicator to react to immediate market shifts that might be smoothed over or missed by standard time-based indicators.
  • Multi-Mode Moving Averages: Once these Tick values are established, the script applies different types of Moving Averages (MA) to them. Depending on your preference, it can calculate:
    • SMA (Simple): A standard average of recent ticks.
    • EMA (Exponential): An average that gives more weight to the most recent data points.
    • SMMA (Wilder’s Smoothing): A weighted moving average used to reduce "noise" in the data.
    • LWMA (Linear Weighted): A calculation where the weight of each tick decreases linearly as it gets older.
  • Dual-Speed Analysis: The logic utilizes a "Fast" and "Slow" dual-line system. By comparing these two smoothed lines, users can identify momentum shifts more clearly than by looking at raw price action alone.

Key Visual & Functional Features

  • Tick Limit Management: To ensure the platform remains responsive and does not overload with unnecessary data, the script limits the amount of historical "tick" information it tracks at one time (defined by a user-set maximum).
  • Visual Delimiters: The tool includes an option to draw vertical dotted lines on the chart. These act as visual markers to separate different periods of analysis, helping traders keep track of specific market cycles or significant shifts in time.
  • Real-Time Array Shifting: Because "ticks" happen much faster than candles form, the script constantly rearranges its internal data arrays. This ensures that every new price movement is placed at the forefront of the calculation while pushing older data back, maintaining a live stream of relevant information.

Summary for the User

In short, this script takes the Adaptive RSI, extracts the "heartbeat" of the market (the Ticks), and then applies professional-grade smoothing filters to that heartbeat. This provides a visual representation of momentum that is highly sensitive to immediate price changes while remaining filtered enough to be readable and actionable for trend analysis.

Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
TickAdaptiveRSI_v1
//+------------------------------------------------------------------+
//|                                         TickAdaptiveRSI_v1.1.mq4 |
//|                                Copyright © 2008, TrendLaboratory |
//|                          Many Thanks to Rosh for Ticks indicator |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                   E-mail: igorad2003@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, TrendLaboratory"
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"


#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 DodgerBlue
#property indicator_color3 Tomato
//---- buffers
extern int     ARSIPeriod  =    14;
extern int     FastMA      =     5; //Fast MA Length(Period)
extern int     SlowMA      =    14; //Slow MA Length(Period)
extern int     MA_Mode     =     0; //MA Mode: 0-SMA,1-EMA,2-Wilder(SMMA),3-LWMA 
extern int     UseDelimiter=     1;
extern color   DelimColor  =  Gray; //Color of Bars Delimiter 
extern int     MaxTicks    =   200; //Max Number of ticks   

double Ticks[];
double Fast[];
double Slow[];
double ARSI[];

int      tickCounter=0;
int      delimeterCounter;
datetime pTime;
string   short_name, setup;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, Ticks);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1, Fast);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2, Slow);
   SetIndexBuffer(3, ARSI);
   
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
   short_name="TickAdaptiveRSI_v1("+ARSIPeriod+","+FastMA+","+SlowMA+","+MA_Mode+","+UseDelimiter+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"ARSI");
   SetIndexLabel(1,"Fast");
   SetIndexLabel(2,"Slow");
   
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
      
   setup = short_name+": ";
   pTime = Time[0];
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//----
   ObjDel(setup);
//----
   return(0);
}

void SetDelimeter()
{
//----
   string delimeterName = setup + TimeToStr(Time[0]);
   
   int handle=WindowFind(short_name);
   if(!ObjectCreate(delimeterName,OBJ_VLINE,handle,Time[0],0))
   {
   Print("Error delimiter:",GetLastError());
   }
   else 
   {
   ObjectSet(delimeterName,OBJPROP_COLOR,DelimColor);
   ObjectSet(delimeterName,OBJPROP_STYLE,STYLE_DOT);
   }
}

void ShiftArray()
{
   
   for(int cnt=tickCounter-1; cnt > 0; cnt--)
   {
   ARSI[cnt] = ARSI[cnt-1];
   Ticks[cnt] = Ticks[cnt-1];
   Fast [cnt] = Fast[cnt-1];
   Slow [cnt] = Slow[cnt-1];
   }
   
   if (UseDelimiter!=0)
   {
      for (int j=0;j<ObjectsTotal();j++)
      {
      int NumStr = StringFind(ObjectName(j),setup,0);
      
         if (NumStr == 0)
         {
         datetime Time1=ObjectGet(ObjectName(j),OBJPROP_TIME1);
         int BarTime1=iBarShift(NULL,0,Time1);
         Time1 = Time[BarTime1+1];
         ObjectSet(ObjectName(j),OBJPROP_TIME1,Time1); 
            if( BarTime1+1 > MaxTicks )
            {
               if (!ObjectDelete(ObjectName(j)))
               {
               int _GetLastError = GetLastError();
               Print("ObjectDelete: ",ObjectName(j)," Error #", _GetLastError );
               }
            }
         }       
      }
   }      
}

bool isNewBar()
{
   bool res=false;
   if (Time[0]!=pTime)
   {
   res=true;
   pTime=Time[0];
   }   

   return(res);
}

bool ObjDel(string name)
{
   int _GetLastError = 0;
     
   while(ObjFind(name,0,0) > 0)
   {
      int obtotal = ObjectsTotal();
      for (int i = 0; i < obtotal;i++)
      {
         if (StringFind(ObjectName(i),name,0) >= 0)
         {
            if (!ObjectDelete(ObjectName(i)))
            {
            _GetLastError = GetLastError();
            Print( "ObjectDelete( \"",ObjectName(i),"\" ) - Error #", _GetLastError );
            }
         }
      }
   }      
   if(_GetLastError > 0) return(false);
   else
   return (true);
}
//-----
int ObjFind(string name,int start, int num)
{
   int cnt = 0;
   
   for (int i = 0; i < ObjectsTotal();i++)
      if (StringFind(ObjectName(i),name,start) == num) cnt+=1;
   
   return(cnt);
}         
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   if(tickCounter == 0)
   {
      for(int i=Bars-1;i>=0;i--)
      {
      Ticks[i]= 0.0; //EMPTY_VALUE;
      Fast[i]=0.0;//EMPTY_VALUE;
      Slow[i]=0.0;//EMPTY_VALUE;//0.0;
      }
   }
   
   tickCounter++;

   if(tickCounter >= MaxTicks) 
   {
   tickCounter = MaxTicks; 
   Ticks[tickCounter]=0.0;
   Fast[tickCounter]=0.0;
   Slow[tickCounter]=0.0;
   }
   
   if (isNewBar()) {if(UseDelimiter == 1) SetDelimeter();}
   else
   ShiftArray();
      
   ARSI[0]=iCustom(NULL,0,"Adaptive RSI",ARSIPeriod,0,0);
   
   if(ARSI[1] < 2*ARSI[0])  Ticks[0] = (ARSI[0] - ARSI[1])*10000;
   
   //Print("0=",ARSI[0]," 1=",ARSI[1]," t=",Ticks[0]);
   
   if(MA_Mode == 0)
   {
   if(tickCounter>=FastMA+ARSIPeriod) Fast[0] = TickSMA(Ticks,FastMA);          
   if(tickCounter>=SlowMA+ARSIPeriod) Slow[0] = TickSMA(Ticks,SlowMA);
   }   
   else
   if(MA_Mode == 1)
   {
   if(tickCounter == FastMA) Fast[0] = TickSMA(Ticks,FastMA);  
   else if(tickCounter > FastMA) Fast[0] = TickEMA(Ticks,Fast,FastMA);
   if(tickCounter == SlowMA) Slow[0] = TickSMA(Ticks,SlowMA);  
   else if(tickCounter > SlowMA) Slow[0] = TickEMA(Ticks,Slow,SlowMA);
   }
   else
   if(MA_Mode == 2)
   {
   if(tickCounter == 2*FastMA-1) Fast[0] = TickSMA(Ticks,2*FastMA-1);  
   else if(tickCounter > 2*FastMA-1) Fast[0] = TickEMA(Ticks,Fast,2*FastMA-1);
   if(tickCounter == 2*SlowMA-1) Slow[0] = TickSMA(Ticks,2*SlowMA-1);  
   else if(tickCounter > 2*SlowMA-1) Slow[0] = TickEMA(Ticks,Slow,2*SlowMA-1);
   }
   if(MA_Mode == 3)
   {
   if(tickCounter>=FastMA+ARSIPeriod) Fast[0] = TickLWMA(Ticks,FastMA);          
   if(tickCounter>=SlowMA+ARSIPeriod) Slow[0] = TickLWMA(Ticks,SlowMA);
   }   
   
//----
   return(0);
}
//+------------------------------------------------------------------+
double TickSMA(double array[],int per)
{
   double Sum = 0;
   for(int i = 0;i < per;i++) Sum += array[i];
   return(Sum/per);
}                

double TickEMA(double array1[],double array2[],int per)
{
   return(array2[1] + 2.0/(1+per)*(array1[0] - array2[1]));
}

double TickLWMA(double array[],int per)
{
   double Sum = 0;
   double Weight = 0;
   
      for(int i = 0;i < per;i++)
      { 
      Weight+= (per - i);
      Sum += array[i]*(per - i);
      }
   if(Weight>0) double lwma = Sum/Weight;
   else lwma = 0; 
   return(lwma);
}                          

Comments