Linear Price Bar_v2
Download scriptOverview of the Linear Price Bar Indicator
The Linear Price Bar is a specialized visual tool designed to simplify how price action is interpreted on a trading chart. Rather than focusing on the absolute price of an asset (e.g., whether it is at $100 or $1,000), this indicator strips away the nominal value to highlight the relative movement and "shape" of each individual candle.
How the Logic Works
The core functionality of this script relies on a process called normalization. Here is a breakdown of how it transforms data for your view:
1. Relative Movement Calculation The indicator looks at every price bar on your chart and calculates its movement relative to its own opening price. Specifically, it determines:
- How far the price climbed above the open (the "High" movement).
- How far the price dropped below the open (the "Low" movement).
- The final distance of the closing price from the starting point.
By doing this, the indicator converts every candle into a linear value where the "zero point" is the opening price of that specific period.
2. Visual Classification To make the data easier to read at a glance, the script categorizes every bar into three distinct types:
- Positive Movement: When a candle closes higher than it opened.
- Negative Movement: When a candle closes lower than it opened.
- Neutral Movement: When the closing price remains exactly the same as the opening price.
3. Data Visualization The indicator then plots these calculations into a separate window below your main chart using a histogram format. It uses a color-coded system to distinguish between different types of movements:
- It tracks the upward and downward reach of the bars using specific colors (Blue and Red).
- For bullish candles (where the close is higher than the open), it highlights the specific closing distance.
- For bearish candles (where the close is lower than the open), it highlights that movement instead, ensuring you can visually distinguish between "winning" and "losing" price actions based on their relative magnitude.
Summary for Traders
Essentially, this tool acts as a "magnifying glass" for volatility and candle shape. It ignores the absolute price levels of the market and instead creates a clean, normalized visual representation of how much momentum each bar had. This allows you to more easily identify the strength of price movements and the consistency of trends without the "noise" of large price numbers.
//+------------------------------------------------------------------+
//| Linear Price Bar.mq4 |
//| Copyright © 2006, Keris2112 |
//| none |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Keris2112"
#property link "none"
//----
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,3);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM,EMPTY,3);
SetIndexBuffer(3,ExtMapBuffer4);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
int UpDays, DownDays, NeutralDays;
double BarH, BarL, BarC;
//----
for(i=0; i<Bars; i++)
{
BarH=High[i]-Open[i];
BarL=Low[i]-Open[i];
BarC=Close[i]-Open[i];
if(BarC>0) UpDays+=1;
else if(BarC<0) DownDays +=1;
else if(BarC==0) NeutralDays +=1;
//----
ExtMapBuffer1[i]=BarH;
ExtMapBuffer2[i]=BarL;
// SortBuffer1[i] = BarH;
// SortBuffer2[i] = BarL;
if(Close[i]>Open[i])
{
ExtMapBuffer3[i]=BarC;
ExtMapBuffer4[i]=0;
}
else
{
ExtMapBuffer3[i]=0;
ExtMapBuffer4[i]=BarC;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments