TheTurtleTradingChannelRaw
Download scriptThis tool is designed to provide visual guidance for traders by identifying key price levels based on historical highs and lows. It follows a logic inspired by classic trend-following methodologies, specifically focusing on capturing market momentum while providing clear boundaries for potential entries and risk management.
How the Logic Works
The script analyzes the price action of a selected asset over two distinct timeframes simultaneously. By looking at different "windows" of history, it identifies four specific price lines:
1. Trend Identification (The Outer Channel) The tool first looks back at a larger period of time (defined by the Trade Period). It scans this historical window to find the highest price point and the lowest price point reached.
- The Upper Line: Represents the "breakout" point from recent highs. In trading terms, if the price climbs above this level, it signals potential upward momentum.
- The Lower Line: Represents the "breakout" point from recent lows. If the price drops below this level, it indicates a potential downward shift in trend.
2. Risk Management (The Inner Channel) Simultaneously, the tool performs a second, much narrower scan using a smaller timeframe (defined by the Stop Period). This creates an inner set of boundaries.
- The Longs Stop Line: This is derived from the highest point reached in the very recent past. It acts as a reference point for traders who are looking to buy; if the price retreats back toward this level, it may indicate that the upward move is losing steam.
- The Shorts Stop Line: This is derived from the lowest point reached in the recent past. For those looking to sell, this line serves as a guide for where the immediate "floor" of the price movement sits.
Key Features and Behavior
- Dynamic Calculation: The tool automatically recalculates these levels as new candles form on your chart, ensuring that the boundaries move in real-time with the market's volatility.
- Confirmation Filter: You can choose whether the indicator updates instantly as the price moves or waits for a candle to close before finalizing the levels. This allows you to filter out "noise" and only react to confirmed price actions.
- Visual Clarity: The logic separates these four components into distinct visual styles (solid lines vs. dotted lines) so that you can easily distinguish between your primary trend targets and your immediate risk boundaries at a single glance.
//+------------------------------------------------------------------+
//| TheTurtleTradingChannel_Raw.mq4
//| Copyright © Pointzero-indicator.com
//+------------------------------------------------------------------+
#property copyright "Copyright © Pointzero-indicator.com"
#property link "http://www.pointzero-indicator.com"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#property indicator_color3 DarkSlateGray
#property indicator_color4 DarkSlateGray
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 1
#property indicator_width4 1
#property indicator_style3 STYLE_DOT
#property indicator_style4 STYLE_DOT
//---- indicator parameters
extern bool CalculateOnBarClose = true;
extern int TradePeriod = 10;
extern int StopPeriod = 5;
//---- indicator buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// Drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
// Name and labels
IndicatorShortName("Turtle Channel Raw("+ TradePeriod +"-"+ StopPeriod +")");
SetIndexLabel(0,"Upper line");
SetIndexLabel(1,"Lower line");
SetIndexLabel(2,"Longs Stop line");
SetIndexLabel(3,"Shorts Stop line");
// Buffers
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
// Us :-)
Comment("Copyright © http://www.pointzero-indicator.com");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// More vars here too...
int start = 0;
int limit;
int counted_bars = IndicatorCounted();
// check for possible errors
if(counted_bars < 0)
return(-1);
// Only check these
limit = Bars - 1 - counted_bars;
// Check if ignore bar 0
if(CalculateOnBarClose == true) { start = 1; }
// Check the signal foreach bar
for(int i = limit; i >= start; i--)
{
// Highs and lows
double rhigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, TradePeriod,i+1));
double rlow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, TradePeriod, i+1));
double shigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, StopPeriod,i+1));
double slow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, StopPeriod, i+1));
// It might be recalculating bar zero
ExtMapBuffer1[i] = rhigh;
ExtMapBuffer2[i] = rlow;
ExtMapBuffer3[i] = shigh;
ExtMapBuffer4[i] = slow;
}
// Bye Bye
return(0);
}
Comments