Tick_on_Chart
Download scriptThis script is designed to provide a real-time visual representation of price movement dynamics on your trading chart. Its primary goal is to track the current market price (the "Bid") and analyze its position relative to recent historical highs and lows within a specific timeframe.
Core Functionality
The logic operates by maintaining a rolling window of data points. Rather than looking at the entire history of a currency pair, it focuses on a defined period (set by the user) to capture immediate market sentiment.
1. Price Tracking and History Buffer Every time the market moves, the script updates a internal "memory" of prices. It continuously shifts these data points so that it always holds the most recent information at the forefront. This allows the tool to understand how the price has behaved leading up to the current moment.
2. High and Low Identification As the script processes these data points, it constantly monitors the "peaks" and "valleys." It identifies the highest price reached and the lowest price reached within the specified observation window. By comparing the current price against these extremes, the tool can gauge whether the market is currently trending strongly, consolidating, or showing signs of exhaustion.
3. Visual Feedback and Signaling The script translates these calculations into visual elements on a separate indicator window:
- Trend Visualization: It plots the history of prices captured in the buffer to show the flow of movement.
- Dynamic Range Indicators: The script monitors the distance between the current price and the identified highs/lows. If the price moves significantly close to these extremes, the script highlights specific points. This acts as a visual cue for traders to identify when the price is approaching "ceiling" or "floor" levels based on recent volatility.
4. Update Frequency To ensure the chart remains readable and doesn't create unnecessary visual clutter, the script performs full updates at regular intervals. This balances the need for real-time responsiveness with a smooth visual experience for the user.
Summary for the Trader
In simple terms, this tool acts as a "memory" for the market. It remembers where the price has been over the last few hundred ticks, identifies the highest and lowest points in that range, and alerts you visually when the current price is nearing those boundaries. It is designed to help you see the immediate structure of the market at a glance.
//+------------------------------------------------------------------+
//| Tick_on_Chart.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
int tik,t;
double buf[],MaxB,MinB=1000;
//----
extern int period=200;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_SECTION);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_NONE);
SetIndexBuffer(1,ExtMapBuffer2);
//----
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);
if(tik==0)
{
for(i=0;i<b;i++)
{
buf[i]=Bid;
}
ExtMapBuffer2[0]=Bid+5*Point;
ExtMapBuffer2[1]=Bid-5*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];
}
buf[0]=Bid;
for(i=0;i<b;i++)
{
ExtMapBuffer1[i]=buf[i];
}
if(MathCeil(t/10)*10==t)
{
for(i=b;i<Bars;i++)
{
ExtMapBuffer1[i]=Bid;
}
ArrayInitialize(ExtMapBuffer2,Bid);
if(MaxB-Bid<5*Point)ExtMapBuffer2[0]=Bid+5*Point;
if(Bid-MinB<5*Point)ExtMapBuffer2[1]=Bid-5*Point;
//Print(MaxB,"+",Bid,"+",MinB);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments