Gann Hilo Candle Colors & Stairs free
Description
This is a Modified Gann Hilo so that the averages lines changes accordingly to the Trend,
it also comes with a option to change the type of the Moving Average and options to paint
the candle colors follwoing the trend. There's also a option to transform the lines to stairs.
You can find me by joyining this Telegram Group http://t.me/cTraderCoders
Grupo de Telegram Para Brasileiros, Portugueses e todos aqueles que falam portugues:http://t.me/ComunidadeCtrader
Grupo CTrader en Español para Latinos: http://t.me/ComunidadCtrader
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, AccessRights = AccessRights.None)] public class GannHiLoExperto : Indicator { [Parameter("Period", DefaultValue = 13)] public int Period { get; set; } [Parameter("Ma Type", DefaultValue = MovingAverageType.Simple)] public MovingAverageType Matype { get; set; } [Parameter("Candle Colors", DefaultValue = false)] public bool SetColors { get; set; } [Parameter("SmoothLines", DefaultValue = false)] public bool SetSmoothLines { get; set; } [Output("Up", LineColor = "LawnGreen", Thickness = 1, PlotType = PlotType.DiscontinuousLine)] public IndicatorDataSeries UpSeries { get; set; } [Output("Down", LineColor = "Red", Thickness = 1, PlotType = PlotType.DiscontinuousLine)] public IndicatorDataSeries DownSeries { get; set; } private IndicatorDataSeries MainLine; private IndicatorDataSeries downSeries; private IndicatorDataSeries upSeries; private MovingAverage maHigh; private MovingAverage maLow; protected override void Initialize() { MainLine = CreateDataSeries(); upSeries = CreateDataSeries(); downSeries = CreateDataSeries(); maHigh = Indicators.MovingAverage(Bars.HighPrices, Period, Matype); maLow = Indicators.MovingAverage(Bars.LowPrices, Period, Matype); } public override void Calculate(int index) { double close = Bars.ClosePrices[index]; double HighMa = maHigh.Result[index - 1]; double HighPrevMa = maHigh.Result[index - 2]; double LowMa = maLow.Result[index - 1]; double LowPrevMa = maLow.Result[index - 2]; if (SetSmoothLines) { UpSeries[index] = LowMa; DownSeries[index] = HighMa; } upSeries[index] = LowMa; downSeries[index] = HighMa; if (close > HighMa) { //**************************************************** if (SetSmoothLines) { MainLine[index] = UpSeries[index]; DownSeries[index] = double.NaN; } else { Chart.DrawTrendLine("Up Horizontal" + index, index - 1, upSeries[index], index, upSeries[index], Color.SpringGreen); Chart.DrawTrendLine("Up Vertical" + index, index - 1, upSeries[index - 1], index - 1, upSeries[index], Color.SpringGreen); } //**************************************************** if (SetColors) { if (Bars.ClosePrices[index] >= Bars.OpenPrices[index]) Chart.SetBarColor(index, Color.SpringGreen); else Chart.SetBarColor(index, Color.Green); } } else { if (close < LowMa) { //****************************************************s if (SetSmoothLines) { MainLine[index] = DownSeries[index]; UpSeries[index] = double.NaN; } else { Chart.DrawTrendLine("Down Horizontal" + index, index - 1, downSeries[index], index, downSeries[index], Color.Red); Chart.DrawTrendLine("Down Vertical" + index, index - 1, downSeries[index - 1], index - 1, downSeries[index], Color.Red); } //**************************************************** if (SetColors) { if (Bars.ClosePrices[index] <= Bars.OpenPrices[index]) Chart.SetBarColor(index, Color.Red); else Chart.SetBarColor(index, Color.Coral); } } else { if (MainLine[index - 1] == HighPrevMa) { if (SetSmoothLines) { MainLine[index] = DownSeries[index]; UpSeries[index] = double.NaN; } else { Chart.DrawTrendLine("Down Horizontal" + index, index - 1, downSeries[index], index, downSeries[index], Color.Red); Chart.DrawTrendLine("Down Vertical" + index, index - 1, downSeries[index - 1], index - 1, downSeries[index], Color.Red); } if (SetColors) { if (Bars.ClosePrices[index] <= Bars.OpenPrices[index]) Chart.SetBarColor(index, Color.Red); else Chart.SetBarColor(index, Color.Coral); } } else { //**************************************************** if (SetSmoothLines) { MainLine[index] = UpSeries[index]; DownSeries[index] = double.NaN; } else { Chart.DrawTrendLine("Up Horizontal" + index, index - 1, upSeries[index], index, upSeries[index], Color.SpringGreen); Chart.DrawTrendLine("Up Vertical" + index, index - 1, upSeries[index - 1], index - 1, upSeries[index], Color.SpringGreen); } //**************************************************** if (SetColors) { if (Bars.ClosePrices[index] >= Bars.OpenPrices[index]) Chart.SetBarColor(index, Color.SpringGreen); else Chart.SetBarColor(index, Color.Green); } } } } } } }
Comments