Kijun-Sen_v1

Download script
Author: Copyright � 2004, AlexSilver � ����� +
Kijun-Sen_v1

This script is designed to enhance your trading charts by automatically calculating and visualizing a key component of the Ichimoku Kinko Hyo technical analysis system: the Kijun-sen (Baseline).

The primary goal of this tool is to provide traders with a clearer sense of the market's medium-term trend and equilibrium. Here is a breakdown of how the logic works in simple terms:

Core Functionality

The script scans historical price data to identify specific price levels over a set period. Instead of just looking at the current price, it evaluates the highest point reached (High) and the lowest point reached (Low) within a defined window of time (specifically 26 periods).

By taking these two extremes—the highest peak and the lowest valley—and calculating their average, the script identifies a "balance point." This balance point is then plotted on your chart as a smooth line.

Key Logic Features

  • Trend Identification: The resulting line acts as a visual guide for the market's direction. When price is moving significantly above or below this line, it helps traders determine whether the current momentum is bullish (upward) or bearish (downward).
  • Time Offsetting (Shifting): The script includes a "Shift" mechanism. This intentionally moves the calculated line forward on the chart. This shift is designed to help align the data with current market movements, allowing for a more relevant comparison between historical averages and live price action.
  • Dynamic Calculation: The logic is built to update constantly. As new candles form and old ones expire, the script recalculates the highest highs and lowest lows, ensuring the line stays responsive to real-time market fluctuations.

How it helps you as a trader

Rather than forcing you to manually calculate complex averages, this script automates the heavy lifting. It provides a clear, visual "baseline" on your screen that simplifies your decision-making process. By seeing where the price sits in relation to this calculated equilibrium, you can better identify potential areas of support, resistance, and trend changes at a glance.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
Kijun-Sen_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                     Ichimoku.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                      Copyright © 2004, AlexSilver â ïëàíå +      |
//|                                       http://www.metaquotes.net/ |
//|                                       http://www.viac.ru/        |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, AlexSilver â ïëàíå +"
#property link      "http://www.viac.ru/"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int Kijun=26;
extern int KijunShift=9;
//---- buffers
double Kijun_Buffer[];
//----
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- Âûâîä Kijun-sen
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Kijun_Buffer);
   SetIndexDrawBegin(1,Kijun+KijunShift-1);
   SetIndexShift(1,KijunShift);
   SetIndexLabel(1,"Kijun Sen");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Ichimoku Kinko Hyo                                               |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k;
   double u=0;
   int    counted_bars=IndicatorCounted();
   double high,low,price;
//----
   if(Bars<=Kijun) return(0);
//---- initial zero
   if(counted_bars<1)
     {
      for(i=1;i<=Kijun;i++)     Kijun_Buffer[Bars-i]=0;
     }

//---- Kijun Sen
   i=Bars-Kijun;
   if(counted_bars>Kijun) i=Bars-counted_bars-1;
   while(i>=0)
     {
      high=High[i]; low=Low[i]; k=i-1+Kijun;
      while(k>=i)
        {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price) low=price;
         k--;
        }
      Kijun_Buffer[i+KijunShift]=(high+low)/2;
      i--;
     } i=KijunShift-1;
   while(i>=0)
     {
      high=High[0]; low=Low[0]; k=Kijun-KijunShift+i;
      while(k>=0)
        {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price) low=price;
         k--;
        }
      Kijun_Buffer[i]=(high+low)/2;
      
      i--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments