SHI Channel11_v1

Download script
Author: Copyright � 2004, Shurka & Kevin
SHI Channel11_v1

This technical tool is designed to analyze price action on a trading chart by identifying specific structural trends and establishing a visual "channel" based on historical market behavior. Instead of simply following every small price movement, the logic focuses on significant highs and lows to define the primary direction and momentum of the market.

Core Logic Overview

1. Significant Point Identification The script begins by scanning a specific range of historical data (based on the timeframe you are viewing) to find two key anchor points: a significant local high and a significant local low. It uses a "fractal" logic, which means it looks for peaks and valleys that stand out against their immediate neighbors rather than just any price movement.

2. Trend Calculation Once these two primary points are identified, the script calculates the "Slope"—the rate at which the price is moving up or down over time—and the "Step," which represents the mathematical distance between these points. This allows the tool to understand the trajectory of the market trend.

3. Projection and Channel Construction Using the data from these two anchor points, the script projects a three-part channel onto your chart:

  • The Median Line: A center path that represents the core equilibrium of the current trend.
  • Upper and Lower Boundaries: Two outer lines that create a "tunnel" or corridor. These boundaries are mathematically derived to represent the expected range of price volatility based on the calculated slope.

4. Dynamic Adjustments The script is designed to be responsive. It checks the most recent price action against these projected boundaries. If the current market price breaks outside of the expected path established by the historical anchors, it identifies these "extremes" as potential points of interest.

Summary for the User

In simple terms, this script looks at past market history to find the "main highway" of price movement. It then draws a corridor (a channel) on your current chart showing where the price is expected to travel based on that historical trend. It provides you with a visual representation of the market's momentum, helping you see whether the price is staying within its normal range or if it is moving in a way that deviates from the established trend.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
SHI Channel11_v1
//+------------------------------------------------------------------+
//|                                                  SHI_Channel11.mq4 |
//|                                 Copyright © 2004, Shurka & Kevin |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, Shurka & Kevin"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 Red
double ExtMapBuffer1[];
double midBuffer1[];
double ABuffer1[];
double BBuffer1[];
//---- input parameters
extern int       AllBars=240;
extern int       BarsForFract=0;
int CurrentBar=0;
double Step=0;
int B1=-1,B2=-1;
int UpDown=0;
double P1=0,P2=0,PP=0;
int i=0,AB=300,BFF=0;
int ishift=0;
double iprice=0;
datetime T1,T2;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,164);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,midBuffer1);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ABuffer1);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,BBuffer1);
 
//----
	
	
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }

void DelObj()
{
	ObjectDelete("TL1");
	ObjectDelete("TL2");
	ObjectDelete("MIDL");
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- 
	if ((AllBars==0) || (Bars<AllBars)) AB=Bars; else AB=AllBars; //AB-êîëè÷???âî î??÷è?ûâà??û? ?à?îâ
	if (BarsForFract>0) 
		BFF=BarsForFract; 
	else
	{
		switch (Period())
		{
			case 1: BFF=12; break;
			case 5: BFF=48; break;
			case 15: BFF=24; break;
			case 30: BFF=24; break;
			case 60: BFF=12; break;
			case 240: BFF=15; break;
			case 1440: BFF=10; break;
			case 10080: BFF=6; break;
			default: DelObj(); return(-1); break;
		}
	}
	CurrentBar=2; //?÷è?à?? ? ????ü??î ?à?à, ÷?î?û ô?àê?àë "çàê??ïèë??
	B1=-1; B2=-1; UpDown=0;
	while(((B1==-1) || (B2==-1)) && (CurrentBar<AB))
	{
		//UpDown=1 ç?à÷è? ï??âûé ô?àê?àë ?àé??? ?â????, UpDown=-1 ç?à÷è? ï??âûé ô?àê?àë
		//?àé??? ??èç?, UpDown=0 ç?à÷è? ô?àê?àë ?ù¸ ?? ?àé???.
		//A1 è A2 - ?î???à ?à?îâ ? ô?àê?àëà?è, ÷???ç ?è? ???îè? îïî???? ëè?è?.
		//?1 è ?2 - ?îî?â????â???î ???û ÷???ç êî?î?û? ????? ëè?è? ï?îâî?è?ü

		if((UpDown<1) && (CurrentBar==Lowest(Symbol(),Period(),MODE_LOW,BFF*2+1,CurrentBar-BFF))) 
		{
			if(UpDown==0) { UpDown=-1; B1=CurrentBar; P1=Low[B1]; }
			else { B2=CurrentBar; P2=Low[B2];}
		}
		if((UpDown>-1) && (CurrentBar==Highest(Symbol(),Period(),MODE_HIGH,BFF*2+1,CurrentBar-BFF))) 
		{
			if(UpDown==0) { UpDown=1; B1=CurrentBar; P1=High[B1]; }
			else { B2=CurrentBar; P2=High[B2]; }
		}
		CurrentBar++;
	}
	if((B1==-1) || (B2==-1)) {DelObj(); return(-1);} // C?à÷è? ?? ?à?ëè ô?àê?àëîâ ????è 300 ?à?îâ 8-)
	Step=(P2-P1)/(B2-B1);//Aû÷è?ëèëè ?à?, ??ëè î? ïîëî?è??ëü?ûé, ?î êà?àë ?è??î??ùèé
	P1=P1-B1*Step; B1=0;//ï?????àâë??? ???? è ï??âûé ?à? ê ??ë?
	//A ??ï??ü îïî???? ?î÷ê? ï?î?èâîïîëî??îé ëè?èè êà?àëà.
	ishift=0; iprice=0;
	if(UpDown==1)
	{ 
		PP=Low[2]-2*Step;
		for(i=3;i<=B2;i++) 
		{
			if(Low[i]<PP+Step*i) { PP=Low[i]-i*Step; }
		}
		if(Low[0]<PP) {ishift=0; iprice=PP;}
		if(Low[1]<PP+Step) {ishift=1; iprice=PP+Step;}
		if(High[0]>P1) {ishift=0; iprice=P1;}
		if(High[1]>P1+Step) {ishift=1; iprice=P1+Step;}
	} 
	else
	{ 
		PP=High[2]-2*Step;
		for(i=3;i<=B2;i++) 
		{
			if(High[i]>PP+Step*i) { PP=High[i]-i*Step;}
		}
		if(Low[0]<P1) {ishift=0; iprice=P1;}
		if(Low[1]<P1+Step) {ishift=1; iprice=P1+Step;}
		if(High[0]>PP) {ishift=0; iprice=PP;}
		if(High[1]>PP+Step) {ishift=1; iprice=PP+Step;}
	}
	//??ï??ü ï?????àâè? êî??÷??? ???? è ?à? ?à AA, ÷?î?û ëè?èè êà?àëà ?è?îâàëè?ü ïî?ëè????
	P2=P1+AB*Step;
	T1=Time[B1]; T2=Time[AB];

	//??ëè ?? ?ûëî ï?????÷??è? êà?àëà, ?î 0, è?à÷? ??àâè? ï?è??.
	if(iprice!=0) ExtMapBuffer1[ishift]=iprice;
	
	for(i=0;i<=240;i++)
   {
	if (Step<=0)
	{
	midBuffer1[i]=(P1+PP)/2-MathAbs(Step*i);
	ABuffer1[i]=(P1+PP)/2-MathAbs(Step*i)+MathAbs(PP - P1)/2;
	BBuffer1[i]=(P1+PP)/2-MathAbs(Step*i)-MathAbs(PP - P1)/2;
	}
	else
	{
		midBuffer1[i]=(P1+PP)/2+MathAbs(Step*i);
		ABuffer1[i]=(P1+PP)/2+MathAbs(Step*i)+MathAbs(PP - P1)/2;
   	BBuffer1[i]=(P1+PP)/2+MathAbs(Step*i)-MathAbs(PP - P1)/2;
	}
	}
	DelObj();
 
		Comment(" Channel size = ", DoubleToStr(MathAbs(PP - P1)/Point,0), " Slope = ", DoubleToStr(-Step/Point, 2));
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments