Fixing obsolete cTrader, cAlgo C# Csharp code 2023, Chart Objects

Created at 03 Nov 2023, 13:52
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
SI

siisbiz

Joined 23.09.2020

Fixing obsolete cTrader, cAlgo C# Csharp code 2023, Chart Objects
03 Nov 2023, 13:52


Hello Every1

I am very new to coding and started updating old code on my self, well I am trying..

I would like some help on how to fix obsolete code in VS 2022, the correct way, step by step. where to find in which register, how to read the code, how to transfer, translate old definitions to new ones.

Please use the code underneath as an example, and please only links and vids from 2023, anything older is the past ;)

Thank you for any help

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

namespace cAlgo.Indicators

{
    [Levels(0)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class CyfMomHistogramCMH13a : Indicator
    {
        //////// Drawing on the Indicator ///////
        private string Up = "▲";
        private string Down = "▼";
        ////////////////////////////////////////

        public MomentumOscillator CMH_13a;
        //private int RefCandle;

        //private IndicatorDataSeries CMH;

        [Parameter()]
        public DataSeries CMH_Source { get; set; }
        
        [Parameter(DefaultValue = 12)]
        public int CMH_Periods { get; set; }


        [Output("Momentum_Up", LineColor = "DarkGreen", PlotType = PlotType.Histogram, Thickness = 2)]
        public IndicatorDataSeries MoScillatorUp { get; set; }
        
        [Output("Momentum_Down", LineColor = "DarkOrange", PlotType = PlotType.Histogram, Thickness = 2)]
        public IndicatorDataSeries MoScillatorDown { get; set; }

        



        protected override void Initialize()
        {
        
        //System.Diagnostics.Debugger.Launch();

            CMH_13a = Indicators.MomentumOscillator(CMH_Source, CMH_Periods);


        }
        public override void Calculate(int index)
        {
            double momentum = CMH_13a.Result[index];

            if (CMH_13a.Result[index] >= 100.0)
            {
                MoScillatorUp[index] = (CMH_13a.Result[index] - 100.0);

                ChartObjects.RemoveObject("Direction");
                ChartObjects.DrawText("Direction", Up, StaticPosition.BottomRight, Colors.Green);

            }
            else
            {
                ChartObjects.RemoveObject("Direction");

                MoScillatorDown[index] = (CMH_13a.Result[index] - 100.0);
                ChartObjects.DrawText("Direction", Down, StaticPosition.BottomRight, Colors.Red);

            }
        }


    }
}


@siisbiz
Replies

PanagiotisCharalampous
04 Nov 2023, 06:31

Hi there, 

There is no specific guide for this so it is better to rephrase your request to specific questions so that we can answer them.

Best regards,

Panagiotis


@PanagiotisCharalampous