Description
Salam,
Heikin Ashi with macd
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);
}
}
}
MA
ma4fekih
Joined on 02.08.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Haiken MACD.algo
- Rating: 0
- Installs: 1264
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.