MACD Clossover Marker free

by summer in category Oscilator at 15/10/2020
Description

MACD Clossoverがゴールデンクロスしたとき買いのマーク、デッドクロスしたとき売りのマークを表示します。

Put a buy mark when the MACD Clossover crosses golden and a sell mark when it crosses dead.

 

website

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.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());
            }
        }
    }
}
Comments
0