Category Other  Published on 05/06/2023

RSISTOCHMACD ON CHART (cloud)

Description

This is an update version that has been smoothed

to 7 bars that gives it a SMA as the base line.


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;

namespace cAlgo
{
     [Cloud ( "RSI", "RSI50", Opacity = 0.8 , FirstColor = "RSI", SecondColor = "RSI50")]
      
     [Cloud ( "SCH", "SCH50", Opacity = 0.6 , FirstColor = "SCH", SecondColor = "SCH50")]
     
     [Cloud ( "Macd", "Signal", Opacity = 1 , FirstColor = "Macd", SecondColor = "Signal")]
    
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    
    public class RSISCHON : Indicator
    
    {    // EMA FFAA4400   SMA  FF88AA44 50 AA7733AA P 88554488//
    
    
        public DataSeries Source { get; set; }
   
        [Parameter("RSI Period",Group = "These Defaults are for AUDUSD", DefaultValue = 14)]
        public int RPeriod { get; set; }

        
        
        [Output("RSI", LineColor = "AA00AA00" )]
        public IndicatorDataSeries RSI { get; set; }
        
        [Output("RSI50", LineColor = "AAFF4400" )]
        public IndicatorDataSeries RSI50 { get; set; }
        

        [Parameter("maType",Group = "These Defaults are for AUDUSD")]
        public MovingAverageType MAType { get; set; }
        
        [Parameter("K%",Group = "These Defaults are for AUDUSD", DefaultValue = 14)]
        public int KPeriod { get; set; } 
        
        [Parameter("Slowing",Group = "These Defaults are for AUDUSD", DefaultValue = 3)]
        public int KSlowing { get; set; }
    
        [Parameter("D%",Group = "These Defaults are for AUDUSD", DefaultValue = 3)]
        public int DPeriod { get; set; }
        
      
        [Output("SCH", LineColor = "AA0000AA" )]
        public IndicatorDataSeries SCH { get; set; }
        
        [Output("SCH50", LineColor = "AAAA0000" )]
        public IndicatorDataSeries SCH50 { get; set; }
        
        
        [Parameter("Long Cycle",Group = "These Defaults are for AUDUSD", DefaultValue = 26)]
        public int LongCycle { get; set; }

        [Parameter("Short Cycle",Group = "These Defaults are for AUDUSD", DefaultValue = 12)]
        public int ShortCycle { get; set; }

        [Parameter("Signal Periods",Group = "These Defaults are for AUDUSD", DefaultValue = 9)]
        public int Periods { get; set; }
        

        [Output("Macd", LineColor = "44FFFF00",Thickness =1, PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries Macd {get;set;}

        [Output("Signal", LineColor = "44AA00FF",Thickness =1, PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries Signal {get;set;}

        

        
        
        
        
        [Parameter("Factor 1 Sets RSI and Stochastic to Close Price ",Group = "These Defaults are for AUDUSD", DefaultValue = 25000)]
        public int F1 { get; set; }
        
        [Parameter("Factor 2 Sets RSI and Stochastic to Close Price",Group = "These Defaults are for AUDUSD", DefaultValue = 333)]
        public int F2 { get; set; }
        
        [Parameter("Factor 3 Sets Macd to Close Price",Group = "These Defaults are for AUDUSD", DefaultValue = 100)]
        public int F3 { get; set; }
        
        [Parameter("Factor 4 Sets Macd to Close Price",Group = "These Defaults are for AUDUSD", DefaultValue = 10)]
        public int F4 { get; set; }
        
        
        private RelativeStrengthIndex rsi;
        
        private StochasticOscillator sch;
        
        private MacdCrossOver macdCrossOver;

        protected override void Initialize()
        {
           rsi = Indicators.RelativeStrengthIndex(Source, RPeriod);
            
           sch = Indicators.StochasticOscillator(KPeriod, KSlowing, DPeriod, MAType);
           
           macdCrossOver = Indicators.MacdCrossOver(LongCycle, ShortCycle, Periods);
        }
        

        public override void Calculate(int index)
        {
         var C1 = Bars.ClosePrices.Last(1);var C2 = Bars.ClosePrices.Last(2);var C3 = Bars.ClosePrices.Last(3);
         var C4 = Bars.ClosePrices.Last(4);var C5 = Bars.ClosePrices.Last(5);var C6 = Bars.ClosePrices.Last(6);
         var C7 = Bars.ClosePrices.Last(7);
         
         var O1 = Bars.OpenPrices.Last(1);var O2 = Bars.OpenPrices.Last(2);var O3 = Bars.OpenPrices.Last(3);
         var O4 = Bars.OpenPrices.Last(4);var O5 = Bars.OpenPrices.Last(5);var O6 = Bars.OpenPrices.Last(6);
         var O7 = Bars.OpenPrices.Last(7);
         
         var X = (C1+O1+C2+O2+C3+O3+C4+O4+C5+O5+C6+O6+C7+O7)/14;
         
         RSI[index] = rsi.Result[index] / F1 + X - ( X / F2 ) ;
         
         RSI50[index] = X;
         
        
         SCH[index] = sch.PercentK[index] / F1 + X - ( X / F2 ) ;
         
         SCH50[index] = X;
         
         
         Macd[index] = macdCrossOver.MACD[index] * (( X * F3 + X ) * X / F4 ) + X ;

         Signal[index] = macdCrossOver.Signal[index] * (( X * F3 + X ) * X / F4 ) + X ;
        
        }
    }
}

VE
VEI5S6C4OUNT0

Joined on 06.12.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: RSISTCHMACD ON CHART.algo
  • Rating: 5
  • Installs: 600
  • Modified: 05/06/2023 12:54
Comments
Log in to add a comment.
No comments found.