Simple Ichimoku Kinko Hyo Cloud█  OVERVIEW 
This indicator as an educational and showcase the usage of  user-defined types or objects (UDT)  for Ichimoku Kinko Hyo or Ichimoku Cloud.
 █  CREDITS 
 TradingView
Chikou
Exponentially Deviating Moving Average (MZ EDMA)Exponentially Deviating Moving Average (MZ EDMA) is derived from Exponential Moving Average to predict better exit in top reversal case.
 EDMA  Philosophy 
EDMA is calculated in following steps: 
 
 In first step, Exponentially expanding moving line is calculated with same code as of EMA but with different smoothness (1 instead of 2).
 In 2nd step, Exponentially contracting moving line is calculated using 1st calculated line as source input and also using same code as of EMA but with different smoothness (1 instead of 2).
 In 3rd step, Hull Moving Average with 3/2 of EDMA length is calculated using final line as source input. This final HMA will be equal to Exponentially Deviating Moving Average.
 
 EDMA  Advantages 
 
 EDMA's main advantage is that in case of top price reversal it deviates from conventional EMA of 2*Length. This benefits in using EDMA for EMA cross with quick signals avoiding unnecessary crossovers. EDMA's deviation in case of top reversal can be seen as below:
 EDMA presents better smoothened curve which acts as better Support and resistance. EDMA coparison with conventional EMA of 2*length of EDMA is as follows.
 
 Additional Features 
 
 EMA Band:  EMA band is shown on chart to better visualize EMA cross with EDMA.
 Dynamic Coloring:   Chikou  Filter library is used for derivation of dynamic coloring of EDMA and its band.
 Alerts:  Alerts are provided of all trade signals. Weak buy/sell would trigger if EMA of 2*EDMA_length crosses EDMA. Strong buy/sell would trigger if EMA of same length as of EDMA crosses EDMA.
 Trade Confirmation with  Chikou  Filter:  Trend filteration from  Chikou  filter library is used as an option to enhance trades signals accuracy.
 
 Defaults 
Currently default EDMA and EMA1 length is set to 20 period which I've found better for higher timeframes but this can be adjusted according to user's timeframe. I would soon add Multi Timeframe option in script too.  Chikou  filter's period is set to 25.
ChikouLibrary   "Chikou" 
This library contains Chikou Filter function to enhances functionality of Chikou-Span from Ichimoku Cloud using a simple trend filter.
Chikou is basically close value of ticker offset to close and it is a good for indicating if close value has crossed potential Support/Resistance zone from past. Chikou is usually used with 26 period.
Chikou filter uses a lookback length calculated from provided lookback percentage and checks if trend was bullish or bearish within that lookback period.
 Bullish  : Trend is bullish if Chikou span is above high values of all candles within defined lookback period. Bull color shows bullish trend .
 Bearish : Trend is bearish if Chikou span is below low values of all candles within defined lookback period. This is indicated by Bearish color.
 Reversal / Choppiness  : Reversal color indicates that Chikou are swinging around candles within defined lookback period which is an indication of consolidation or trend reversal.
 chikou(src, len, perc, _high, _low, bull_col, bear_col, r_col)  Chikou Filter for Ichimoku Cloud with Color and Signal Output
  Parameters:
     src : Price Source (better to use (OHLC4+high+low/3 instead of default close value)
     len : Chikou Legth (displaced source value) 
     perc : Percentage lookback period for Chikou Filter with defined how much candels of total length should be considered for backward filteration
     _high : Ticker High Value
     _low : Ticker Low Value
     bull_col : Color to be returned if source value is greater than all candels within provided lookback percentage.
     bear_col : Color to be returned if source value is lower than all candels within provided lookback percentage.
     r_col : Color to be returned if source value is swinging around candles within defined lookback period which is an indication of consolidation or trend reversal.
  Returns: Color based on trend. 'bull_col' if trend is bullish, 'bear_col' if trend is bearish. 'r_col' if no prominent trend. Integer Signal is also returned as 1 for Bullish, -1 for Bearish and 0 for no prominent trend.
Chikou Filter for Ichimoku CloudThis Indicator enhances functionality of Chikou-Span from Ichimoku Cloud using a simple trend filter.
  Methodology 
Chikou is basically close value of ticker offset to close and it is a good for indicating if close value has crossed potential Support/Resistance zone from past. Chikou is usually used with 26 period.
Chikou filter uses a lookback length calculated from provided lookback percentage and checks if trend was bullish or bearish within that lookback period.
  Bullish :  Trend is bullish if Chikou span is above high values of all candles within defined lookback period. Green color shows bullish trend.
  Bearish:  Trend is bearish if Chikou span is below low values of all candles within defined lookback period. This is indicated by red color.
  Reversal / Choppiness :  White color indicates that Chikou are swinging around candles within defined lookback period which is an indication of consolidation or trend reversal.
 Default Settings 
Different source types are included but I've found that (OHLC4+High+Low)/3 is better for Chikou and Symmetrically Weighted Moving Average (SWMA) is also applied but it produce some repainting though. Default period is set to 26 and lookback percentage is 50%. Low percentage would decrease filter's efficiency.
 Usage 
This filter can be used to check if Chikou crossover has occurred in past. This can be used with Donchain channels, Bollinger Bands or any Moving Average as replacement of High / Low values. I'll use this indicator in all my Ichimoku Cloud studies especially adaptive ones. Filter outputs in Color and Integer format; both can be used as signals definitions.



