Tick_Chart_+_Weighted

Author: Copyright � 2005, MetaQuotes Software Corp.
Tick_Chart_+_Weighted

This script is a specialized trading tool designed to provide traders with a visual representation of price movement by tracking three distinct types of data simultaneously. Rather than simply showing a standard line, it creates a multi-layered view of the market's "heartbeat," focusing on real-time liquidity and weighted averages.

Core Functionality

The tool operates by monitoring four different data streams to help users distinguish between actual price action and broader market sentiment:

  • Bid and Ask Tracking: The script captures the current Bid (the price at which you can sell) and the Ask (the price at which you can buy). By separating these, it allows traders to see the "spread" and the immediate availability of liquidity.
  • Weighted Price Calculation: Instead of relying solely on a single closing price, the script calculates a specific weighted average. It takes into account the daily highs, lows, and closing prices to create a more balanced representation of where the price actually settled during a period.
  • Dynamic Range Monitoring: The logic identifies the highest and lowest points reached within a user-defined window (the "period"). This helps in understanding the volatility of recent price action.

How it Works for the User

The script performs several automated tasks behind the scenes to ensure the data remains relevant:

  1. Data Buffer Management: It maintains a history of these prices over a specific number of ticks. This creates a "moving window" of information, ensuring that the visual display reflects recent activity without being overwhelmed by old, irrelevant data.
  2. Proximity Alerts: The script constantly compares the current market price against the highest and lowest points recorded in its memory. If the price gets dangerously close to these historical extremes (based on a user-defined "width"), it highlights those boundaries.
  3. Continuous Updating: The indicator refreshes automatically. It ensures that every time the price moves, the weighted averages and the bid/ask levels are recalculated, providing a smooth, real-time flow of information in a separate viewing window.

Summary of Purpose

For a trader, this tool serves as a sophisticated "multi-lens" view. Instead of seeing just one line moving up and down, you see the relationship between what the market is offering to buy (Bid), what it is asking to sell (Ask), and a weighted "true" price—all while being alerted to the boundaries of recent price highs and lows.

Miscellaneous
Implements a curve of type %1
7 Views
0 Downloads
0 Favorites
Tick_Chart_+_Weighted
//+------------------------------------------------------------------+
//|                                        Tick Chart + Weighted.mq4 |
//|     Copyright © 2005, MetaQuotes Software Corp. © 2010, J.Arent. |
//|              http://www.metaquotes.net/, http://www.fxtools.info |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Cornsilk
#property indicator_color3 Blue
#property indicator_color4 Gray

extern int period=2000;
extern int width=50;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
int tik,t;
double buf[],buf2[],buf3[],MaxB,MinB=1000;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_SECTION);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_SECTION,EMPTY,2);
   SetIndexBuffer(3,ExtMapBuffer4);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,b;
//---- 
t++;
b=period;
ArrayResize(buf,b); 
ArrayResize(buf2,b); 
ArrayResize(buf3,b); 

if(tik==0)
   {
   for(i=0;i<b;i++)
      {
      buf[i]=Bid;
      buf2[i]=Ask;
      buf3[i]=(High[0]+Low[0]+Close[0]+Close[0])/4;
      }
   ExtMapBuffer2[0]=Bid+width*Point;   
   ExtMapBuffer2[1]=Bid-width*Point;   
   tik=1;
   }
   MaxB=0;MinB=1000;
   for(i=b-1;i>0;i--)
      {
      buf[i]=buf[i-1];
      if(MaxB<buf[i])MaxB=buf[i];
      if(MinB>buf[i])MinB=buf[i];
      buf2[i]=buf2[i-1];
      if(MaxB<buf2[i])MaxB=buf2[i];
      if(MinB>buf2[i])MinB=buf2[i];
      buf3[i]=buf3[i-1];
      if(MaxB<buf3[i])MaxB=buf3[i];
      if(MinB>buf3[i])MinB=buf3[i];
      } 
buf[0]=Bid;
buf2[0]=Ask;
buf3[i]=(High[0]+Low[0]+Close[0]+Close[0])/4;
for(i=0;i<b;i++)
   {
   ExtMapBuffer1[i]=buf[i];
   ExtMapBuffer3[i]=buf2[i];
   ExtMapBuffer4[i]=buf3[i];
   }
if(MathCeil(t/10)*10==t)
   {
   for(i=b;i<Bars;i++)
      {
      ExtMapBuffer1[i]=Bid;
      ExtMapBuffer3[i]=Ask;
      ExtMapBuffer4[i]=(High[0]+Low[0]+Close[0]+Close[0])/4;  
      }
      ArrayInitialize(ExtMapBuffer2,Bid); 
      if(MaxB-Bid<width*Point)ExtMapBuffer2[0]=Bid+width*Point;
      if(Bid-MinB<width*Point)ExtMapBuffer2[1]=Bid-width*Point;
   }   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments