Ticks_mod_v1.0a

Author: Rosh
Ticks_mod_v1.0a

This script is designed as a specialized market tracking tool for the MetaTrader platform. Its primary purpose is to monitor and visualize high-frequency price movements—specifically "ticks"—which are the tiny, instantaneous changes in price that occur between the standard candles seen on a chart.

Here is a breakdown of how the logic functions:

High-Frequency Data Tracking

Unlike standard indicators that only update when a new candle forms, this script operates on every single price fluctuation (tick). It tracks three specific pieces of information simultaneously:

  • Bid Price: The current price at which a seller is willing to sell.
  • Ask Price: The current price at which a buyer is willing to buy.
  • Opening Price: The price at which the current candle began.

Visual Representation and Memory Management

The script maintains a visual history of these movements in a separate window. To ensure the platform remains stable and responsive, it includes a "memory management" system:

  • Draw Limits: It keeps track of a specific number of recent ticks (defined by the user).
  • Array Shifting: Every time a new price change occurs, the script "shifts" the previous data points forward in line to make room for the newest price. This creates a fluid, moving visual history of the market's pulse.
  • Dynamic Delimiters: The script automatically places vertical dashed lines on the chart to separate different trading sessions or periods, helping the user distinguish between different blocks of time visually.

Price Movement Analytics

Beyond just showing the lines, the script performs real-time calculations to analyze the direction and intensity of price movement:

  • Delta Calculation: It calculates the mathematical difference between the previous tick and the current tick.
  • Directional Counting: The logic categorizes every move as either a positive increase or a negative decrease.
  • Real-Time Statistics: It maintains running totals for how many times the price moved up versus how many times it moved down.

User Interface Feedback

The script provides an interactive feedback loop on the screen by displaying a live summary. At all times, the user can see:

  1. A calculated path of price movements.
  2. A "Plus" count (total upward movements).
  3. A "Minus" count (total downward movements).

In summary, this tool acts as a high-resolution microscope for price action, allowing a trader to see the micro-movements of the market that are often hidden by standard candle charts, while providing a running tally of the market's volatility and direction.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
Ticks_mod_v1.0a
//+------------------------------------------------------------------+
//|                                                        Ticks.mq4 |
//|                                                       MetaQuotes |
//|                    http://www.alpari-idc.ru/ru/experts/articles/ |
//+------------------------------------------------------------------+
#property copyright "Rosh"
#property link      "http://www.alpari-idc.ru/ru/experts/articles/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Lime
//---- buffers
extern int MaxDrawTicks=500;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
int myBars;
int tickCounter;
int delimeterCounter;
string nume1,nume2,nume3;
//-----------------------
string Path;
int Counter;
int CounterPlus;
int CounterMinus;
double BidPrev;
//----------------------
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
    int i;
    init_tick();
    nume1 ="Bid_"+Symbol();
    nume2 ="Ask_"+Symbol();    
    nume3 ="Open_"+Symbol();
    GlobalVariableSet(nume1,0);
    GlobalVariableSet(nume2,0);    
    GlobalVariableSet(nume3,0);    
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);   
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexEmptyValue(2,0.0);   
   
   Print("Îáíóëÿåì òèêè");
   for (i=Bars-1;i>=0;i--) ExtMapBuffer1[i]=0.0;
   for (i=Bars-1;i>=0;i--) ExtMapBuffer2[i]=0.0;
   for (i=Bars-1;i>=0;i--) ExtMapBuffer3[i]=0.0;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| ñäâèíåì ìàññèâ                                                   |
//+------------------------------------------------------------------+
void SetDelimeter()
  {
//----
   string delimeterDate=TimeToStr(Time[0]);
   if (myBars!=0)
      {
      Print("Ñòàâèì ðàçäåëèòåëü");      
      int handle=WindowFind("Ticks_mod_v1.0");
      if(!ObjectCreate(delimeterDate,OBJ_VLINE,handle,Time[0],0))
         {
         //Alert("Íåäà÷íàÿ ïîïûòêà ñîçäàíèÿ ðàçäåëèòåëÿ â îêíå ",
         //handle," ïî âðåìåíè ",TimeToStr(CurTime()));
         Print("Îøèáêà ¹",GetLastError(),", èìÿ ðàçäåëèòåëÿ ",delimeterDate);
         }
      else 
         {
         ObjectSet(delimeterDate,OBJPROP_COLOR,Yellow);
         ObjectSet(delimeterDate,OBJPROP_STYLE,STYLE_DASHDOT);
         ObjectsRedraw();           
         }
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| ñäâèíåì ìàññèâ                                                   |
//+------------------------------------------------------------------+
void ShiftArray()
  {
//----
   int V_lines,i1;
   string delimeterName;
   datetime firstTime;
   int BarFirstTime;
   
   if (tickCounter>2*MaxDrawTicks)
      {
      for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer1[i1]=0.0;
      for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer2[i1]=0.0;
      for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer3[i1]=0.0;            
      tickCounter=MaxDrawTicks;
      }
   for(int cnt=tickCounter;cnt>0;cnt--)
      {
      ExtMapBuffer1[cnt]=ExtMapBuffer1[cnt-1];
      ExtMapBuffer2[cnt]=ExtMapBuffer2[cnt-1];
      ExtMapBuffer3[cnt]=ExtMapBuffer3[cnt-1];      
      }
   V_lines=ObjectsTotal();
   for (int z=0;z<V_lines;z++)
      {
      delimeterName=ObjectName(z); 
      if (ObjectFind(delimeterName)!=-1)
         {
         if (ObjectType(delimeterName)==OBJ_VLINE) 
            {
            firstTime=ObjectGet(delimeterName,OBJPROP_TIME1);
            BarFirstTime=iBarShift(NULL,0,firstTime);
            firstTime=Time[BarFirstTime+1];
            ObjectSet(delimeterName,OBJPROP_TIME1,firstTime); 
            }
         }       
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| ïðèçíàê íîâîãî áàðà                                              |
//+------------------------------------------------------------------+
bool isNewBar()
  {
//----
   bool res=false;
   if (myBars!=Bars)
   {
      res=true;
      myBars=Bars;
   }   
//----
   return(res);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   if (isNewBar())
      {
      // óñòàíîâèòü ðàçäåëèòåëü
      //tickCounter++;
      init_tick();
      SetDelimeter();
      ExtMapBuffer1[0]=Bid;      
      ExtMapBuffer2[0]=Ask;   
      ExtMapBuffer3[0]=Open[0];         
      GlobalVariableSet(nume1,Bid);
      GlobalVariableSet(nume2,Ask);            
      GlobalVariableSet(nume3,Open[0]);        
      }
   else
      
      {
      tickCounter++;
      ShiftArray();
      ExtMapBuffer1[0]=Bid;      
      ExtMapBuffer2[0]=Ask;      
      ExtMapBuffer3[0]=Open[0];               
      GlobalVariableSet(nume1,Bid);
      GlobalVariableSet(nume2,Ask);         
      GlobalVariableSet(nume3,Open[0]);              
      }      
//----
   path1(Symbol());
   Comment("");
   Comment("\nPath: ",Path,
           "\nPlus:",CounterPlus,"   Minus:",CounterMinus);   
   return(0);
  }
//+------------------------------------------------------------------+

void init_tick()
{
   Path="";
   Counter=0;
   CounterPlus=0;
   CounterMinus=0;
   
   BidPrev=MarketInfo(Symbol(),MODE_BID);
}

void path1(string symbol1)
{
  int PathLimit =767;


  
  double Deltha = MarketInfo(symbol1,MODE_BID) * MathPow(10, MarketInfo(symbol1,MODE_DIGITS)) - 
                  BidPrev * MathPow(10, MarketInfo(symbol1,MODE_DIGITS));                
  
  //if(Deltha !=0)
  if (Deltha >= 0) 
    Path = StringConcatenate("+",DoubleToStr ( Deltha, 0 ), Path);
  else
    Path = StringConcatenate( DoubleToStr ( Deltha, 0 ), Path );
  
  Path = StringSubstr ( Path, 0, PathLimit ); 
  if (MarketInfo(symbol1,MODE_BID)!= BidPrev){
      Counter ++;             
      if ((Deltha > 0) && (Deltha !=0)) 
        CounterPlus++;
      if ((Deltha < 0) && (Deltha !=0)) 
        CounterMinus++;
      
      BidPrev = MarketInfo(symbol1,MODE_BID); //  
      }
  

}

Comments