Category Trend  Published on 02/04/2024

Ggg

Description

algo



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");
                }
            }
        }

    }



}



AB
abduhamidbaqoev9

Joined on 02.04.2024

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: LT_Ind_OX.algo.txt
  • Rating: 0
  • Installs: 288
  • Modified: 02/04/2024 20:30
Comments
Log in to add a comment.
mr.ch1371's avatar
mr.ch1371 · 2 months ago

change its extension to .algo and them double click