Heikin MACD free

by ma4fekih in category Other at 12/09/2022
Description

Salam,

Heikin Ashi with macd

 

 

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
Language: C#
Trading Platform: cAlgocTrader
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
 
namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class HeikenAshiSmoothed : Indicator
    {
        private IndicatorDataSeries _haOpen, _haClose;
        private ExponentialMovingAverage ema_short, ema_long, ema_signal;        
        
        [Parameter("Periode EMA Long",Group ="MACD", DefaultValue =100)]
        public int periode_ema_long { get; set; }
        [Parameter("Periode EMA Short",Group ="MACD", DefaultValue =28)]
        public int periode_ema_short { get; set; }
        [Parameter("Period Signal",Group ="MACD", DefaultValue = 6)]
        public int periode_signal { get; set; }
        
        [Output("Green Candle", PlotType = PlotType.Histogram, Color = Colors.Green, Thickness = 9)]
        public IndicatorDataSeries candle_g { get; set; }
        [Output("Red Candle", PlotType = PlotType.Histogram, Color = Colors.Red, Thickness = 9)]
        public IndicatorDataSeries candle_r { get; set; }
        
        [Output("upper vertical Candle line", PlotType = PlotType.Histogram, Color = Colors.Green, Thickness = 1)]
        public IndicatorDataSeries uvcl { get; set; }
        [Output("Lower Vertical Candle Line", PlotType = PlotType.Histogram, Color = Colors.Red, Thickness = 1)]
        public IndicatorDataSeries lvcl { get; set; }
        
        [Output("MACD", Color = Colors.Yellow, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries macd { get; set; }
        [Output("Signal", Color = Colors.LightSkyBlue, LineStyle = LineStyle.Lines, Thickness = 1)]
        public IndicatorDataSeries Signal { get; set; }
        
        
        
 
 
        protected override void Initialize()
        {
            _haOpen = CreateDataSeries();
            _haClose = CreateDataSeries();
            
            ema_long = Indicators.ExponentialMovingAverage(Bars.ClosePrices, periode_ema_long);
            ema_short = Indicators.ExponentialMovingAverage(Bars.ClosePrices, periode_ema_short);
            ema_signal = Indicators.ExponentialMovingAverage(macd, periode_signal);
        }
 
        public override void Calculate(int index)
        {
 
            var open = MarketSeries.Open[index];
            var high = MarketSeries.High[index];
            var low = MarketSeries.Low[index];
            var close = MarketSeries.Close[index];
 
            var haClose = (open + high + low + close) / 4;            
            double haOpen = index > 0 ? (_haOpen[index - 1] + _haClose[index - 1]) / 2 : (open + close) / 2;
            var haHigh = Math.Max(Math.Max(high, haOpen), haClose);
            var haLow = Math.Min(Math.Min(low, haOpen), haClose);
            
            _haOpen[index] = haOpen;
            _haClose[index] = haClose;
            
            var green_color = haClose > haOpen ? true : false;
            
            if(green_color)
                candle_g[index]= haClose - haOpen;
            else
                candle_r[index]= haClose - haOpen;
                
            uvcl[index]= haHigh - haOpen;
            lvcl[index]= haLow - haOpen;
                
            macd[index]=ema_short.Result[index] - ema_long.Result[index] ;
            Signal[index] = ema_signal.Result[index];

            ChartObjects.DrawHorizontalLine("0" , 0, Colors.White);
                
        }
    }
}
Comments

jackjohnsonpo - September 22, 2022 @ 13:19

  I miss your tremendous writings. Past few posts are just a little bit out of track!  io games

gemma140622 - November 08, 2022 @ 05:26

I found your page after conducting an odd Internet search. This essay is excellent. It is encouraging to see that some people continue to put forth great effort to maintain their website's mapquest driving directions.

0