Silver-channels

Download script
Author: Copyright � 2004, AlexSilver
Silver-channels

The Silver-channels script is a technical analysis tool designed to project specific price boundaries and zones on a trading chart based on historical price action. Rather than following a single moving average, it identifies the "envelope" of price movement over a set period to establish structural levels for traders.

Core Logic Overview

The indicator operates by analyzing the highest and lowest prices achieved within a predefined window of time (the "lookback period"). By identifying these extremes, the script creates four distinct types of price channels:

  • Standard Channels (Silver & Sky): These are calculated as percentage-based offsets from the high and low points. They represent specific retracement levels (such as 38.2% or 23.6%) within the current price range. These are often used by traders to identify potential support and resistance zones where the price might stall or reverse.
  • The Zen Channel: This represents the raw boundaries of the analyzed period, capturing the absolute high and low prices reached during the lookback timeframe.
  • Future Channels: Unlike the other channels which move with the current data, these are designed to project potential expansion points. They extend the current range forward by a specific percentage (61.8%), helping traders visualize where price might travel if the current momentum continues.

How it Processes Data

The script follows a structured two-phase calculation process to ensure the visual lines are accurate:

  1. Historical Mapping: The tool first scans the historical data on your chart. It looks back at the required number of bars to establish the "base" channels. This ensures that the historical trend is correctly mapped according to the chosen percentages.
  2. Real-Time Adaptation: As new price data arrives (live ticks), the script recalculates these levels in real-time. It constantly updates the highs and lows to ensure that the Silver, Sky, Zen, and Future channels react immediately to current market volatility.

Visual Representation

The logic produces eight distinct lines on the chart:

  • Four lines for the Silver zones (High/Low).
  • Four lines for the Sky zones (High/Low).
  • Two lines for the Zen boundaries (High/Low).
  • Two lines for the Future projections (High/Low).

By providing these various layers of data simultaneously, the script allows you to see not just where the price is, but where it has been and potential areas where it might go next based on mathematical retracements.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
Silver-channels
//+------------------------------------------------------------------+
//|                                              Silver-channels.mq4 |
//|                                     Copyright © 2004, AlexSilver |
//|                                                  http://viac.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, AlexSilver"
#property link      "http://viac.ru/"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Silver
#property indicator_color2 Silver
#property indicator_color3 SkyBlue
#property indicator_color4 SkyBlue
#property indicator_color5 YellowGreen
#property indicator_color6 YellowGreen
#property indicator_color7 Magenta
#property indicator_color8 Magenta
//---- input parameters
extern int Shift=3;
extern int TSP=9;
extern int SSP=26;
extern double SilvCh=38.2;
extern double SkyCh=23.6;
extern double ZenCh=0;
extern double FutCh=61.8;
//---- buffers
double SCH_BufferH[];
double SCH_BufferL[];
double Sky_BufferH[];
double Sky_BufferL[];
double Zen_BufferH[];
double Zen_BufferL[];
double Fut_BufferL[];
double Fut_BufferH[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//----
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,SCH_BufferH);
   SetIndexDrawBegin(0,SSP+Shift-1);
   SetIndexShift(0,Shift);
   SetIndexLabel(0,"Silver-channel High");
//----
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,SCH_BufferL);
   SetIndexDrawBegin(1,SSP+Shift-1);
   SetIndexShift(1,Shift);
   SetIndexLabel(1,"Silver-channel Low");
//----
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Sky_BufferH);
   SetIndexDrawBegin(2,SSP+Shift-1);
   SetIndexShift(2,Shift);
   SetIndexLabel(2,"Sky-channel High");
//----
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Sky_BufferL);
   SetIndexDrawBegin(3,SSP+Shift-1);
   SetIndexShift(3,Shift);
   SetIndexLabel(3,"Sky-channel Low");
//----
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,Zen_BufferH);
   SetIndexDrawBegin(4,SSP+Shift-1);
   SetIndexShift(4,Shift);
   SetIndexLabel(4,"Zen-channel High");
//----
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,Zen_BufferL);
   SetIndexDrawBegin(5,SSP+Shift-1);
   SetIndexShift(5,Shift);
   SetIndexLabel(5,"Zen-channel Low");
//----
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,Fut_BufferL);
   SetIndexDrawBegin(6,SSP+TSP-1);
   SetIndexShift(6,TSP);
   SetIndexLabel(6,"Future-channel Low");
//----
   SetIndexStyle(7,DRAW_LINE);
   SetIndexBuffer(7,Fut_BufferH);
   SetIndexDrawBegin(7,SSP+TSP-1);
   SetIndexShift(7,TSP);
   SetIndexLabel(7,"Future-channel High");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Silver-channels                                                       |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k;
   int    counted_bars=IndicatorCounted(); // òåêóùèé áàð äëÿ ðàñ÷åòà èíäèêàòîðà
   double high,low,price;
//----
   if(Bars<=SSP) return(0); // åñëè áàðîâ ìåíüøå Êèäæóí-ïåðèîäà íàôèã
//---- initial zero
   if(counted_bars<1) // åñëè òåêóùèé áàð ìåíüøå åäèíèöû - íàôèã ñ ïëÿæà, óñòàíàâëèâàåì âñå â íóëè
     {
      for(i=1;i<=SSP;i++) SCH_BufferH[Bars-i]=0; SCH_BufferL[Bars-i]=0; Sky_BufferH[Bars-i]=0; Sky_BufferL[Bars-i]=0; Zen_BufferH[Bars-i]=0; Zen_BufferL[Bars-i]=0; Fut_BufferL[Bars-i]=0; Fut_BufferH[Bars-i]=0;
     }
//---- ñòàíäàðòíûå âû÷èñëåíèÿ äî 0-ãî áàðà
   i=Bars-SSP;
   if(counted_bars>SSP) i=Bars-counted_bars-1;
   while(i>=0)
     {
      high=High[i]; low=Low[i]; k=i-1+SSP;
      while(k>=i)
        {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price)  low=price;
         k--;
        } // âñå ïîñ÷èòàëè - çàïèñûâàåì çíà÷åíèÿ òî÷êè â ìàññèâ èíäèêàòîðà
      SCH_BufferL[i+Shift]=low+(high-low)*SilvCh/100;
      SCH_BufferH[i+Shift]=high-(high-low)*SilvCh/100;
      Sky_BufferL[i+Shift]=low+(high-low)*SkyCh/100;
      Sky_BufferH[i+Shift]=high-(high-low)*SkyCh/100;
      Zen_BufferL[i+Shift]=low;
      Zen_BufferH[i+Shift]=high;
      Fut_BufferL[i]=low-(high-low)*FutCh/100;
      Fut_BufferH[i]=high+(high-low)*FutCh/100;
      i--; // äâèãàåì ñ÷åò÷èê
     } i=Shift-1; // Ñ÷èòàåì òî÷êè ñäâèãà - ñïðàâà îò íóëåâîãî
   while(i>=0)
     {
      high=High[0]; low=Low[0]; k=SSP-Shift+i; // êàæäûé ñëåäóþùèé óìåíüøàåò ïåðèîä
      while(k>=0)
        {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price)  low=price;
         k--;
        } // çàïèñûâàåì çíà÷åíèÿ â ìàññèâ
      SCH_BufferL[i]=low+(high-low)*SilvCh/100;
      SCH_BufferH[i]=high-(high-low)*SilvCh/100;
      Sky_BufferL[i]=low+(high-low)*SkyCh/100;
      Sky_BufferH[i]=high-(high-low)*SkyCh/100;
      Zen_BufferL[i]=low;
      Zen_BufferH[i]=high;
      i--;
     }
   }
//+------------------------------------------------------------------+

Comments