Category Other  Published on 06/04/2023

LT_Ind_RedGreen

Description

Help to visualize the rising, falling.

Green: rising or unchanged from green.

Red: falling or unchanged from red.

Can apply on any source.

The RedGreen applied on an Instantaneous Trendline:

The RedGreen applied on the MACD crossover histogram:

here they are:


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;
using LittleTrader;
using LittleTrader.Ehlers;
using LittleTrader.Extensions;

namespace cAlgo
{
    [Levels(0)]
    [Indicator(AccessRights = AccessRights.None)]
    public class LT_Ind_RedGreen : Indicator
    {
        [Parameter("SourceType", DefaultValue = SourceTypes.Custom)]
        public SourceTypes SourceType { get; set; }
        [Parameter("CustomSource")]
        public DataSeries CustomSource { get; set; }

        [Output("Up", LineColor = "Green", IsHistogram = true)]
        public IndicatorDataSeries Up { get; set; }
        [Output("Dn", LineColor = "Red", IsHistogram = true)]
        public IndicatorDataSeries Dn { get; set; }

        DataSeries _s;
        protected override void Initialize()
        {
            var u = new IndUtils() { Bars = Bars, SourceType = SourceType, CustomSource = CustomSource };
            _s = u.GetSource();
        }

        public override void Calculate(int index)
        {
            Up[index] = _s.IsGreen(index) ? _s[index] : double.NaN;
            Dn[index] = _s.IsRed(index) ? _s[index] : double.NaN;
        }
    }


}

dhnhuy's avatar
dhnhuy

Joined on 03.04.2023

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: LT_Ind_RedGreen.algo
  • Rating: 0
  • Installs: 618
  • Modified: 06/04/2023 04:12
Comments
Log in to add a comment.
No comments found.