Description
This is what the MACD looks like set onto a chart.
Using the BARS close as the center line
the orange line in this picture is a MA set to 1 for refferance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Cloud ( "Macd", "Signal", Opacity = 1 , FirstColor = "Macd", SecondColor = "Signal")]
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class MACDON : Indicator
{ // Bar Colours are #CCFFFF00 and #FF552277
public DataSeries Source { get; set; }
[Parameter("Long Cycle", DefaultValue = 26)]
public int LongCycle { get; set; }
[Parameter("Short Cycle", DefaultValue = 12)]
public int ShortCycle { get; set; }
[Parameter("Signal Periods", DefaultValue = 9)]
public int Periods { get; set; }
[Output("Macd", LineColor = "4400AA00",Thickness =1, PlotType = PlotType.DiscontinuousLine)]
public IndicatorDataSeries Macd {get;set;}
[Output("Signal", LineColor = "44AA0000",Thickness =1, PlotType = PlotType.DiscontinuousLine)]
public IndicatorDataSeries Signal {get;set;}
private MacdCrossOver macdCrossOver;
protected override void Initialize()
{
macdCrossOver = Indicators.MacdCrossOver(LongCycle, ShortCycle, Periods);
}
public override void Calculate(int index)
{var BAR = Bars.ClosePrices[index];
// The math here works for AUDUSD but changing zeros...here..V.....and....V......
// will scale it to other charts (BAR*100+BAR)*BAR/10)+BAR)
Macd[index] = macdCrossOver.MACD[index]*((BAR*100+BAR)*BAR/10)+BAR;
Signal[index] = macdCrossOver.Signal[index]*((BAR*100+BAR)*BAR/10)+BAR;
{
}
}
}
}
VE
Splash The
Joined 06.12.2022
- Type: Free
- Language: C#
- Trading Platform: cTrader Automate
- Filename: MACD ON CHART.algo
- Rating: 5
- Downloads: 237
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.
Comments
Only logged in users can post a comment
Comments not found