Author: Copyright ?2007, okwh.
okwhticks

This tool is designed as a specialized visual indicator for the MetaTrader trading platform. Its primary purpose is to provide a continuous, real-time stream of price data by capturing and displaying the most recent market prices in a dedicated window.

Core Functionality

Unlike standard charts that might only update at the close of a candle (like a 1-hour or 4-hour bar), this script focuses on "tick" data—the smallest possible increments of price movement. It creates a visual path that tracks the current market price as it fluctuates second by second.

How the Logic Works

The script operates using the following step-by-step logic:

  • Real-Time Tracking: The tool constantly monitors the current "Bid" price (the best currently available Metastore price at which a продавец is willing to sell).
  • Data Smoothing and Buffering: Instead of just showing a single point, the script manages a "buffer" or a history of these prices. It looks back at a specific number of previous price points (defined by a user-set limit) to build a continuous line.
  • Historical Initialization: When the tool is first loaded onto a chart, it performs an initial scan. If there isn't enough immediate data to draw a line, it automatically populates the history using the closing prices of previous bars. This ensures that the indicator has a starting point to work from as soon as it appears on your screen.
  • Dynamic Updating: As new market prices come in, the script shifts the existing history forward. It places the newest price at the front of the line and moves the older data points back by one position. This creates a fluid, moving visual representation of price action.
  • Efficiency Management: The script includes logic to ensure it doesn't over-calculate. By using a limit on the number of bars it tracks, it maintains a smooth performance without taxing your computer's resources.

Summary for the User

In essence, this script transforms raw market "ticks" into a readable line in a separate window. It allows you to see the immediate, granular movement of the price with higher frequency than a standard candlestick chart might provide, helping you visualize the micro-trends of the market in real-time.

Miscellaneous
Implements a curve of type %1
7 Views
0 Downloads
0 Favorites
okwhticks
#property copyright "Copyright ?2007, okwh."
#property link "http://blog.sina.com.cn/FXTrade"

//#property indicator_chart_window
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_color2 Aqua
#property indicator_color3 CornflowerBlue
#property indicator_color4 Gold
#property indicator_color5 SkyBlue
//---- input parameters
extern int  Tbars = 1000; //Ö»¼Ç¼×î½ü1000µã
//---- buffers
double ExtMapBuffer1[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function        tick                 |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

   double nows=0;
int num=0,i=0;

int start()

{
  int Ncounted_bars = Bars-IndicatorCounted();
  if (Ncounted_bars == Bars) //Ê״Σ¬¸´ÖÆcloseÊý¾Ý ²¢ÇÒÓÐʱ¶àÊý¾Ý±ä»¯£¬MT½öµ÷ÓÃÖ¸±êÒ»´Î
  {  
   num = Ncounted_bars;
   for (int i=num;i>0;i--)  
     ExtMapBuffer1[i]= Close[i-1]; //ÒÔ¶ÓÁз½Ê½¼Ç¼ticks ¼Û¸ñ
   return(0);
  }
  nows = MarketInfo(Symbol(),MODE_BID);//MarketInfo(Symbol(),MODE_ASK);//+MarketInfo(Symbol(),MODE_BID))/2.0;
  SetLevelValue(0, nows) ;
  if (Ncounted_bars>1) //ÓÐʱ¶àÊý¾Ý±ä»¯£¬MT½öµ÷ÓÃÖ¸±êÒ»´Î,ÐèÌî³ä¿Õ°× ÓÉÓÚMTµÄÊý¾Ý¸üз½Ê½
   {
    for ( i=Ncounted_bars;i>0;i--)  
     ExtMapBuffer1[i-1]= ExtMapBuffer1[i]; //ÒÔ¶ÓÁз½Ê½¼Ç¼ticks ¼Û¸ñ
   }
  if (num>0) 
   {
     if (nows == ExtMapBuffer1[0]) return (0);//Ö»¼Ç¼Óб仯µÄÊý¾Ý
      if (num>Tbars)num = Tbars;
      for ( i=num;i>0;i--)  
      {
        ExtMapBuffer1[i]= ExtMapBuffer1[i-1]; //ÒÔ¶ÓÁз½Ê½¼Ç¼ticks ¼Û¸ñ
     }
   }
   ExtMapBuffer1[0] =   nows;
   num++;
   WindowRedraw( ) ;
return(0);

}

Comments