Category Range  Published on 29/03/2024

LT_Ind_OX.algo

Description



using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Linq;
using System.Collections.Generic;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AutoRescale = true, AccessRights = AccessRights.None)]
    public class LT_Ind_OX : Indicator
    {
        [Parameter(DefaultValue = 5, MinValue = 1)]
        public double XTick { get; set; }
        [Parameter(DefaultValue = 3, MinValue = 1)]
        public int Periods { get; set; }

        [Parameter(DefaultValue = "Yellow", Group = "Draws")]
        public Color Color { get; set; }

        DonchianChannel _donchian;
        protected override void Initialize()
        {
            _donchian = Indicators.DonchianChannel(Periods);
        }

        bool _curX, _curO;
        public override void Calculate(int index)
        {
            var top = _donchian.Top[index] + Symbol.TickSize * XTick;
            var bot = _donchian.Bottom[index] - Symbol.TickSize * XTick;
            var key = $"Ox_{Bars.OpenTimes[index]}";

            if (Bars.ClosePrices[index] > top && Math.Min(Bars.OpenPrices[index], Bars.ClosePrices[index - 1]) < top)
            {
                var txt = Chart.DrawText($"{key}_x", "x", index, top, Color);
                txt.VerticalAlignment = VerticalAlignment.Center;
                txt.HorizontalAlignment = HorizontalAlignment.Center;
                _curX = true;
            }
            else
            {
                if (_curX)
                {
                    _curX = false;
                    Chart.RemoveObject($"{key}_x");
                }
            }

            if (Bars.ClosePrices[index] < bot && Math.Max(Bars.OpenPrices[index], Bars.ClosePrices[index - 1]) > bot)
            {
                var txt = Chart.DrawText($"{key}_o", "o", index, bot, Color);
                txt.VerticalAlignment = VerticalAlignment.Center;
                txt.HorizontalAlignment = HorizontalAlignment.Center;
                _curO = true;
            }
            else
            {
                if (_curO)
                {
                    _curO = false;
                    Chart.RemoveObject($"{key}_o");
                }
            }
        }

    }



}



 


The author decided to hide the source code.
LE
lenex7459

Joined on 29.03.2024

  • Distribution: Paid
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: LT_Ind_OX 6.algo
  • Rating: 0
  • Installs: 0
Comments
Log in to add a comment.
No comments found.