_Soho_Ichi_Average

_Soho_Ichi_Average

This script is a specialized technical analysis tool designed for the MetaTrader platform. It modifies the traditional Ichimoku Kinko Hyo—a popular "all-in-one" charting method—by applying a smoothed averaging logic to its primary components. Instead of using standard price extremes, this version utilizes Moving Averages (MA) to calculate the different layers of the indicator, aiming to provide a smoother visual representation of market trends and potential reversals.

Core Logic and Components

The script calculates five distinct visual elements on your chart to help identify momentum and equilibrium:

1. The Conversion Line (Tenkan Sen) This represents short-term momentum. The script calculates this by applying a user-defined moving average over a specific period (defaulting to 8 bars). It serves as the primary indicator of immediate price direction.

2. The Base Line (Kijun Sen) This represents medium-term equilibrium. The script uses a longer moving average (defaulting to 24 bars) to establish this line. In market analysis, the relationship between the Conversion Line and the Base Line is often used to identify shifts in trend strength.

3. The Leading Span A (Senkou Span A) Unlike standard Ichimoku calculations that simply average the two previous lines at a specific point, this script calculates the value by taking the mathematical average of the conversion line and the base line at any given moment. This creates a "cloud" boundary that helps define the current trend's trajectory.

4. The Leading Span B (Senkou Span B) This is calculated using a much longer moving average (defaulting to 48 bars). It represents long-term price sentiment. The space between Senkou Span A and Senkou Span B forms the "Kumo" or Cloud, which traders use to identify support and resistance zones.

5. The Lagging Span (Chinkou Span) This component tracks current price action but projects it backward on the chart. By looking at where the current closing price sits relative to past price action (shifted back by the Kijun period), it helps confirm if the current trend has sufficient strength to maintain its direction.

User Customization

The script allows for several "extern" parameters that let you tailor the logic to different timeframes or assets:

  • MA_Type: Allows you to choose the specific type of moving average calculation (e.g., Simple, Exponential, etc.).
  • Price: Defines which price data point is used for the calculations (such as Open, High, Low, or Close).
  • Time Periods: Users can adjust the specific lengths for the Tenkan, Kijun, and Senkou periods to make the indicator more sensitive or more stable depending on their trading style.

Visual Presentation

The script is programmed to render these lines with different styles (solid lines versus dotted histograms) and distinct colors. This visual layering allows a trader to see the "Cloud" (Span A and B) as a background area, while the Conversion and Base lines act as dynamic markers for immediate entry or exit signals.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
3 Views
0 Downloads
0 Favorites
_Soho_Ichi_Average
//+------------------------------------------------------------------+
//|                             ICHIMOKU AVERAGE.mq4 |
//                               BY SOHOCOOL 2012  //
/////////////////////////http://sohocool.over-blog.com////////////
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/
//// ICHIMOKU MODIFIED BY SOHOCOOL TO DO ICHIMOKU AVERAGE IN 2012
//+------------------------------------------------------------------+


#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 SandyBrown
#property indicator_color2 Thistle
#property indicator_color3 Red
#property indicator_color4 Blue
#property indicator_color5 Lime
#property indicator_color6 SandyBrown
#property indicator_color7 Thistle

#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_width6 2
#property indicator_width7 2

//---- input parameters
extern int MA_Type =1;
extern int Price =0;
extern int MA_Tenkan=8;
extern int MA_Kijun=24;
extern int MA_Senkou=48;
//---- buffers
double Tenkan_Buffer[];
double Kijun_Buffer[];
double SpanA_Buffer[];
double SpanB_Buffer[];
double Chinkou_Buffer[];
double SpanA2_Buffer[];
double SpanB2_Buffer[];
//----
int a_begin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  // a_begin=MA_Kijun; if(a_begin<MA_Tenkan) a_begin=MA_Tenkan;
//----
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Tenkan_Buffer);
   SetIndexDrawBegin(2,MA_Tenkan-1);
   SetIndexLabel(2,"Tenkan Sen");
//----
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Kijun_Buffer);
   SetIndexDrawBegin(3,MA_Kijun-1);
   SetIndexLabel(3,"Kijun Sen");
//----
   a_begin=MA_Kijun; if(a_begin<MA_Tenkan) a_begin=MA_Tenkan;
   
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_DOT);
   SetIndexBuffer(0,SpanA_Buffer);
   SetIndexDrawBegin(0,MA_Kijun+a_begin-1);
   SetIndexShift(0,MA_Kijun);
   SetIndexLabel(0,NULL);
   
   SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(5,SpanA2_Buffer);
   SetIndexDrawBegin(5,MA_Kijun+a_begin-1);
   SetIndexShift(5,MA_Kijun);
   SetIndexLabel(5,"Senkou Span A");
//----
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_DOT);
   SetIndexBuffer(1,SpanB_Buffer);
   SetIndexDrawBegin(1,MA_Kijun+MA_Senkou-1);
   SetIndexShift(1,MA_Kijun);
   SetIndexLabel(1,NULL);
   
   SetIndexStyle(6,DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(6,SpanB2_Buffer);
   SetIndexDrawBegin(6,MA_Kijun+MA_Senkou-1);
   SetIndexShift(6,MA_Kijun);
   SetIndexLabel(6,"Senkou Span B");
//----
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,Chinkou_Buffer);
   SetIndexShift(4,-MA_Kijun);
   SetIndexLabel(4,"Chinkou Span");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Ichimoku Kinko Hyo  AVERAGE                                      |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k;
   int    counted_bars=IndicatorCounted();
   double high,low,price;
//----
   if(Bars<=MA_Tenkan || Bars<=MA_Kijun || Bars<=MA_Senkou) return(0);
//---- initial zero
   if(counted_bars<1)
     {
      for(i=1;i<=MA_Tenkan;i++)    Tenkan_Buffer[Bars-i]=0;
      for(i=1;i<=MA_Kijun;i++)     Kijun_Buffer[Bars-i]=0;
      for(i=1;i<=a_begin;i++) { SpanA_Buffer[Bars-i]=0; SpanA2_Buffer[Bars-i]=0; }
      for(i=1;i<=MA_Senkou;i++)  { SpanB_Buffer[Bars-i]=0; SpanB2_Buffer[Bars-i]=0; }
     }
//---- Tenkan Sen
   i=Bars-MA_Tenkan;
   if(counted_bars>MA_Tenkan) i=Bars-counted_bars-1;
   while(i>=0)
     {
     
      Tenkan_Buffer[i]=iMA(Symbol(), 0, MA_Tenkan, 0, MA_Type, Price, i);
      i--;
     }
//---- Kijun Sen
   i=Bars-MA_Kijun;
   if(counted_bars>MA_Kijun) i=Bars-counted_bars-1;
   while(i>=0)
    {
    
      Kijun_Buffer[i]=iMA(Symbol(), 0, MA_Kijun, 0, MA_Type, Price, i);
      i--;
     }
//---- Senkou Span A
   i=Bars-a_begin+1;
   if(counted_bars>a_begin-1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      price=(Kijun_Buffer[i]+Tenkan_Buffer[i])/2;
      SpanA_Buffer[i]=price;
      SpanA2_Buffer[i]=price;
      i--;
     }
//---- Senkou Span B
   i=Bars-MA_Senkou;
   if(counted_bars>MA_Senkou) i=Bars-counted_bars-1;
   while(i>=0)
     {
    
      price=iMA(Symbol(), 0, MA_Senkou, 0, MA_Type, Price, i);
      SpanB_Buffer[i]=price;
      SpanB2_Buffer[i]=price;
      i--;
     }
//---- Chinkou Span
   i=Bars-1;
   if(counted_bars>1) i=Bars-counted_bars-1;
   while(i>=0) { Chinkou_Buffer[i]=Close[i]; i--; }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments