Description
MACD Clossoverがゴールデンクロスしたとき買いのマーク、デッドクロスしたとき売りのマークを表示します。
Put a buy mark when the MACD Clossover crosses golden and a sell mark when it crosses dead.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class MACDClossoverMarker : Indicator
{
[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 SignalPeriods { get; set; }
private MacdCrossOver _macd;
protected override void Initialize()
{
// Initialize and create nested indicators
_macd = Indicators.MacdCrossOver(LongCycle, ShortCycle, SignalPeriods);
}
public override void Calculate(int index)
{
//ゴールデンクロス
if (_macd.Histogram[index - 1] < 0 && _macd.Histogram[index] > 0)
{
Chart.DrawIcon("poMarker1" + Bars.OpenTimes.Last(0).ToString(), ChartIconType.UpArrow, Bars.OpenTimes.Last(0), Bars.LowPrices.Last(0) - (3 * Symbol.PipSize), "Red");
}
else
{
Chart.RemoveObject("poMarker1" + Bars.OpenTimes.Last(0).ToString());
}
//デッドクロス
if (_macd.Histogram[index - 1] > 0 && _macd.Histogram[index] < 0)
{
Chart.DrawIcon("poMarker2" + Bars.OpenTimes.Last(0).ToString(), ChartIconType.DownArrow, Bars.OpenTimes.Last(0), Bars.HighPrices.Last(0) + (3 * Symbol.PipSize), "Yellow");
}
else
{
Chart.RemoveObject("poMarker2" + Bars.OpenTimes.Last(0).ToString());
}
}
}
}
summer
Joined on 10.08.2020
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: MACD Clossover Marker.algo
- Rating: 5
- Installs: 2557
- Modified: 13/10/2021 09:55
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.