Category Oscilators  Published on 12/09/2019

Double RSI

Description

Follow my cTrader Telegram group at https://t.me/cTraderCommunity; everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ https://discord.gg/5GAPMtp and an Instagram page https://www.instagram.com/ctrader_community/

This is a simple double RSI with different levels already marked.


using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Levels(new double[] 
    {
        70,
        80,
        90,
        50,
        30,
        20,
        10
    })]
    [Indicator(IsOverlay = false, ScalePrecision = 0, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DoubleRSI : Indicator
    {
        [Parameter()]
        public DataSeries Source { get; set; }
        [Parameter(DefaultValue = 8)]
        public int Fast { get; set; }
        [Parameter(DefaultValue = 21)]
        public int Slow { get; set; }

        [Output("Fast", LineColor = "RoyalBlue")]
        public IndicatorDataSeries OFast { get; set; }
        [Output("Slow", LineColor = "Red")]
        public IndicatorDataSeries OSlow { get; set; }

        private RelativeStrengthIndex FastRSI, SlowRSI;

        protected override void Initialize()
        {
            FastRSI = Indicators.RelativeStrengthIndex(Source, Fast);
            SlowRSI = Indicators.RelativeStrengthIndex(Source, Slow);
            IndicatorArea.DrawHorizontalLine("90", 90, Color.Red, 1, LineStyle.Solid);
            IndicatorArea.DrawHorizontalLine("80", 80, Color.DarkRed, 1, LineStyle.DotsRare);
            IndicatorArea.DrawHorizontalLine("70", 70, Color.IndianRed, 1, LineStyle.DotsVeryRare);

            IndicatorArea.DrawHorizontalLine("50", 50, Color.FromHex("7BFFC000"), 1, LineStyle.Solid);

            IndicatorArea.DrawHorizontalLine("10", 10, Color.Lime, 1, LineStyle.Solid);
            IndicatorArea.DrawHorizontalLine("20", 20, Color.Green, 1, LineStyle.DotsRare);
            IndicatorArea.DrawHorizontalLine("30", 30, Color.LightGreen, 1, LineStyle.DotsVeryRare);
        }

        public override void Calculate(int index)
        {
            OFast[index] = FastRSI.Result[index];
            OSlow[index] = SlowRSI.Result[index];
        }
    }
}


CY
cysecsbin.01

Joined on 10.11.2018 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: DoubleRSI.algo
  • Rating: 0
  • Installs: 2060
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
DI
dienteciego18 · 1 year ago

Hello, how could I modify the code to draw a histogram instead of the RSI lines?

thanks