channel_breakout_entry_basic
Download scriptThis tool is designed to help traders identify specific price movements by visualizing "channels" on a trading chart. It focuses on identifying moments when the market price breaks out of established historical boundaries, providing clear signals for potential entry points based on classic trading methodologies.
Core Functionality
The script operates by analyzing three different time horizons simultaneously. It looks back at past price action to determine the highest highs and lowest lows over three specific periods (set by the user as 10, 20, and 55 bars). By doing this, it creates a visual "channel" that represents the market's recent boundaries:
- Short-term Channel: Tracks immediate price action.
- Medium-term Channel: Captures broader price trends.
- Long-term Channel: Identifies significant historical price levels.
How it Works (The Logic)
The logic follows a "breakout" philosophy. Instead of guessing where the price will go, the tool waits for the market to push past these established boundaries.
- Trend Identification: The script constantly monitors the highest and lowest prices within the chosen ranges. It draws lines on your chart to show you exactly where these boundaries sit.
- Breakout Detection: When the current price moves beyond one of these boundaries, the tool recognizes it as a potential breakout.
- Visual Signals: The script identifies specific points where the price crosses from "inside" the channel to "outside" it. It uses visual markers (arrows) on the chart to highlight these exact moments, making it easier for a trader to see when a move has officially started.
- Automated Safety Levels (ATR Stops): A key feature of this script is its ability to calculate "Stop Loss" levels automatically using a volatility measure known as ATR (Average True Range).
- Rather than placing a static stop loss, the tool calculates a buffer based on how volatile the market is currently.
- When a breakout occurs, the tool calculates a safety zone below (for buys) or above (for sells) the price. This ensures that your risk management is adjusted to the "speed" of the market—widening during high volatility and tightening during calm periods.
Summary for the Trader
In simple terms, this tool acts as a map. It shows you where the "walls" of the current market trend are. When the price breaks through a wall, the script signals the breakout and simultaneously calculates a mathematically sound safety zone (Stop Loss) based on current market volatility, helping you manage your risk more precisely than manual estimation would allow.
//+------------------------------------------------------------------+
//| channel_breakout_entry.mq4 |
//| with ATR Stop Loss calculation |
//| use this one for drawing channel |
//| and the place for placing initial SL |
//| as described the turtle trading rules |
//+------------------------------------------------------------------+
#property copyright "darmasdt"
#property link "http://indotraders.org"
//----
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 DarkGray
#property indicator_color2 DarkGray
#property indicator_color3 DodgerBlue
#property indicator_color4 DodgerBlue
#property indicator_color5 Tomato
#property indicator_color6 Tomato
#property indicator_color7 LightSkyBlue
#property indicator_color8 Plum
//---- input parameters
extern int Range1=10;
extern int Range2=20;
extern int Range3=55;
extern double atr_factor=2;
extern int atr_range=14;
//---- buffers
double UpBuffer1[];
double DnBuffer1[];
double UpBuffer2[];
double DnBuffer2[];
double UpBuffer3[];
double DnBuffer3[];
double atr_b2[];
double atr_b3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,1);
//SetIndexStyle(6,DRAW_ARROW,STYLE_DOT,1);
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,249);
//SetIndexStyle(7,DRAW_ARROW,STYLE_DOT,1);
SetIndexStyle(7,DRAW_ARROW);
SetIndexArrow(7,249);
SetIndexBuffer(0,UpBuffer1);
SetIndexBuffer(1,DnBuffer1);
SetIndexLabel(0,"trailing_Up");
SetIndexLabel(1,"trailing_Dn");
SetIndexBuffer(2,UpBuffer2);
SetIndexBuffer(3,DnBuffer2);
SetIndexLabel(2,"sys1_Up");
SetIndexLabel(3,"sys1_Dn");
SetIndexBuffer(4,UpBuffer3);
SetIndexBuffer(5,DnBuffer3);
SetIndexLabel(4,"failsafe_Up");
SetIndexLabel(5,"failsafe_Dn");
SetIndexBuffer(6,atr_b2);
SetIndexBuffer(7,atr_b3);
SetIndexLabel(6,"Sys 1 Stp");
SetIndexLabel(7,"Sys 2 Stp");
//---- name for DataWindow and indicator subwindow label
short_name="CBO_entry("+Range1+","+Range2+","+Range3+")";
IndicatorShortName(short_name);
//----
SetIndexDrawBegin(0,0);
SetIndexDrawBegin(1,0);
SetIndexDrawBegin(2,0);
SetIndexDrawBegin(3,0);
SetIndexDrawBegin(4,0);
SetIndexDrawBegin(5,0);
SetIndexDrawBegin(6,0);
SetIndexDrawBegin(7,0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Channel Trend System |
//+------------------------------------------------------------------+
int start()
{
int i;
//----
for(i=Bars-1;i>=0;i--)
{
//Calculating Channel
UpBuffer1[i]=High[Highest(NULL,0,MODE_HIGH,Range1,i+1)];
DnBuffer1[i]=Low[Lowest(NULL,0,MODE_LOW,Range1,i+1)];
//
UpBuffer2[i]=High[Highest(NULL,0,MODE_HIGH,Range2,i+1)];
DnBuffer2[i]=Low[Lowest(NULL,0,MODE_LOW,Range2,i+1)];
//
UpBuffer3[i]=High[Highest(NULL,0,MODE_HIGH,Range3,i+1)];
DnBuffer3[i]=Low[Lowest(NULL,0,MODE_LOW,Range3,i+1)];
//Calculating ATR Stops
if(High[i+1]<=UpBuffer2[i+1] && High[i]>UpBuffer2[i])
{
atr_b2[i]= UpBuffer2[i] - (iATR(NULL,0,atr_range,i+1)*atr_factor);
}
if(High[i+1]<=UpBuffer3[i+1] && High[i]>UpBuffer3[i])
{
atr_b3[i]= UpBuffer3[i] - (iATR(NULL,0,atr_range,i+1)*atr_factor);
}
if(Low[i+1]>=DnBuffer2[i+1] && Low[i]<DnBuffer2[i])
{
atr_b2[i]= DnBuffer2[i] + (iATR(NULL,0,atr_range,i+1)*atr_factor);
}
if(Low[i+1]>=DnBuffer3[i+1] && Low[i]<DnBuffer3[i])
{
atr_b3[i]= DnBuffer3[i] + (iATR(NULL,0,atr_range,i+1)*atr_factor);
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments