ticksvolume
Download scriptThis tool is designed to provide a detailed visual representation of market activity by tracking every single price movement (or "tick") that occurs within a specific timeframe on your trading chart. Unlike standard volume indicators that might only count the number of trades, this script focuses on the actual direction and magnitude of price fluctuations.
How the Logic Works
The script operates by constantly monitoring the live feed of the market. Every time the price moves—even by a tiny fraction—the logic identifies whether that movement was upward or downward and records it in two distinct ways:
1. Price Movement Tracking (Pips/Points) The script calculates the cumulative distance the price has traveled in a specific direction during the current candle.
- If the price moves up, it adds that distance to an "Up" total.
- If the price moves down, it adds that distance to a "Down" total. By converting these raw numbers into "Pips" or "Points," it shows you exactly how much ground the market has covered in each direction.
2. Tick Frequency Tracking In addition to measuring how far the price moved, the script counts how many times the price moved.
- It treats every upward movement as a positive count and every downward movement as a negative count (or vice versa depending on the visual orientation).
- This allows you to see the "intensity" of the market—distinguishing between a single large price jump and many small, rapid movements.
Visual Presentation
The data is displayed in a separate window below your main chart using four different colored histograms. This allows you to observe the tug-of-war between buyers and sellers in real-time:
- Upward Activity: Represented by specific colors (like Navy and LawnGreen), showing the cumulative distance and tick count for bullish movements.
- Downward Activity: Represented by other colors (like FireBrick and Yellow), showing the cumulative distance and tick count for bearish movements.
Key Benefit
The primary goal of this logic is to provide a clearer picture of market momentum. By separating "Distance Traveled" from "Frequency of Movement," it helps traders understand not just where the price is going, but how aggressively it is moving there. For example, it can help identify whether a price move is being driven by heavy, consistent pressure or by erratic, high-frequency fluctuations.
//+------------------------------------------------------------------+
//| TicksVolume.mq4 |
//| Copyright 2013, Viktorov |
//| v4forex@qip.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, Viktorov"
#property link "v4forex@qip.ru"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Navy
#property indicator_color2 LawnGreen
#property indicator_color3 FireBrick
#property indicator_color4 Yellow
#property indicator_width1 4
#property indicator_width2 2
#property indicator_width3 4
#property indicator_width4 2
#property indicator_level1 0
#property indicator_levelcolor Olive
#property indicator_levelstyle STYLE_DOT
double UpBuffer[];
double DnBuffer[];
double UpTick[];
double DnTick[];
double _Bid,_Ask,PriceUp,PriceDn,TickUp,TickDn;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorShortName("TicksVolume");
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_HISTOGRAM);
SetIndexBuffer(0,UpBuffer);
SetIndexBuffer(1,UpTick);
SetIndexBuffer(2,DnBuffer);
SetIndexBuffer(3,DnTick);
SetIndexLabel(0,"Pips up");
SetIndexLabel(1,"Tick up");
SetIndexLabel(2,"Pips down");
SetIndexLabel(3,"Tick down");
IndicatorDigits(Digits);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
static datetime LastBar=0;
datetime CurBar=time[0];
// Ïðè ïîÿâëåíèè íîâîãî áàðà îáíóëÿåì ïåðåìåííûå
if(LastBar!=CurBar)
{
TickUp=0;
TickDn=0;
PriceUp= 0;
PriceDn= 0;
LastBar=CurBar;
}
if(_Bid == 0) _Bid = Bid; // Ïðè ïîÿâëåíèè íîâîãî áàðà èëè ïðè ïåðâîì çàïóñêå ïðèñâàèâàåì ïåðåìåííûì ñîîòâåòñòâóþùèå çíà÷åíèÿ Bid
if(_Ask == 0) _Ask = Ask; // è Ask
//---
if(Bid>_Bid || (_Bid==Bid && _Ask>Ask)) // Åñëè ïðîèçîøëî óâåëè÷åíèå öåíû
{
PriceUp += Bid - _Bid; // Óâåëè÷èì êîëè÷åñòâî ïóíêòîâ ââåðõ
UpBuffer[0] = PriceUp/_Point; // çàïîëíèì áóôåð ñîîòâåòñòâóþùèì çíà÷åíèåì ïóíêòîâ
TickUp++; // Óâåëè÷èì çíà÷åíèå Volume ââåðõ
UpTick[0] = TickUp; // çàïîëíèì áóôåð ñîîòâåòñòâóþùèì çíà÷åíèåì Volume
}
if(Bid<_Bid || (_Bid==Bid && _Ask<Ask)) // Åñëè ïðîèçîøëî óìåíüøåíèå öåíû
{
PriceDn += Bid - _Bid; // Óâåëè÷èì êîëè÷åñòâî ïóíêòîâ âíèç
DnBuffer[0] = PriceDn/_Point; // çàïîëíèì áóôåð ñîîòâåòñòâóþùèì çíà÷åíèåì ïóíêòîâ
TickDn--; // Óâåëè÷èì çíà÷åíèå Volume âíèç
DnTick[0] = TickDn; // çàïîëíèì áóôåð ñîîòâåòñòâóþùèì çíà÷åíèåì Volume
}
_Bid = Bid;
_Ask = Ask;
return(rates_total);
}
//+------------------------------------------------------------------+
Comments