3LineBreak
Download scriptThe 3LineBreak tool is designed to help traders identify significant price structural shifts by detecting "breakouts" from recent highs and lows. Instead of looking at every tiny fluctuation in the market, this script focuses on identifying when the price moves beyond a specific range established over a set number of previous candles.
Core Logic and Behavior
The tool operates based on a "swing" mechanism that switches between identifying upward momentum and downward momentum. Here is how it processes market data:
- Dynamic Range Monitoring: The script looks back at a small, adjustable window of recent price action (defined by the "Lines_Break" parameter). It constantly monitors two specific values within this window: the highest price reached and the lowest price reached.
- Breakout Detection:
- If the market is currently in an "upward" state and the price drops below the lowest point of that recent window, the script recognizes a shift to a "downward" state.
- Conversely, if the market is in a "downward" state and the price climbs above the highest point of that recent window, it recognizes a shift back to an "upward" state.
- Visual Representation: The indicator uses two distinct visual elements (histograms) to display these shifts on your chart:
- When the market is in an Upward Swing, it maps the high and low points of the current candle to highlight that bullish momentum.
- When the market is in a Downward Swing, it effectively "flips" the logic, mapping the data to highlight the bearish momentum.
Summary for the User
Essentially, this script acts as a filter to help you see the "big picture" of price movement. By ignoring minor noise and only reacting when the price breaks out of its recent high or low boundaries, it provides a visual map of the current trend direction, making it easier to identify where momentum is shifting in real-time.
//+------------------------------------------------------------------+
//| 3LineBreak.mq4 |
//| Copyright © 2004, Poul_Trade_Forum |
//| Aborigen |
//| http://forex.kbpauk.ru/ |
//+------------------------------------------------------------------+
#property copyright "Poul Trade Forum"
#property link "http://forex.kbpauk.ru/"
#property indicator_chart_window
#property indicator_buffers 2
//---- input parameters
extern int Lines_Break=3;
extern int CountBars=300;
//---- buffers
double HighBuffer[];
double LowBuffer[];
double VALUE1,VALUE2,Swing=1,OLDSwing;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Red);
SetIndexBuffer(0,HighBuffer);
SetIndexBuffer(1,LowBuffer);
SetIndexEmptyValue(0,0);
SetIndexEmptyValue(1,0);
//---- name for DataWindow and indicator subwindow label
short_name="3LineBreak";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,10);
SetIndexDrawBegin(1,10);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),i,shift;
//---- TODO: add your code here
if (counted_bars==0) counted_bars=Lines_Break+1;
i=(CountBars-counted_bars);//
for (shift=i; shift>=0;shift--)
{
OLDSwing=Swing;
VALUE1=High[Highest(NULL,0,MODE_HIGH,Lines_Break,shift+1)];
VALUE2= Low[Lowest(NULL,0,MODE_LOW,Lines_Break,shift+1)];
if (OLDSwing==1 && Low[shift]<VALUE2) Swing=-1;
if (OLDSwing==-1 && High[shift]>VALUE1 ) Swing=1;
if (Swing==1)
{ HighBuffer[shift]=High[shift]; LowBuffer[shift]=Low[shift]; }
if (Swing==-1)
{ LowBuffer[shift]=High[shift]; HighBuffer[shift]=Low[shift]; }
//----
}
return(0);
}
//+------------------------------------------------------------------+
Comments