New Features in cTrader Automate API 3.7

Problems with substitutions

I'm still having issues with substituting new API definitions. I tried to do exactly as the warning messages direct, but still unable to find the correct format and getting error messages.

I have:

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


namespace cAlgo.Indicators
{

    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class HighestHighLowestLow2 : Indicator
    {

        [Parameter(" Period", DefaultValue = 10, MinValue = 1)]
        public int Period { get; set; }

        [Parameter(" Timeframe")]
        public TimeFrame AnotherTimeFrame { get; set; }

        [Output("Close Up", LineColor = "Red")]
        public IndicatorDataSeries CloseUp { get; set; }

        [Output("High", LineColor = "Pink")]
        public IndicatorDataSeries High { get; set; }

        [Output("Close Down", LineColor = "Blue")]
        public IndicatorDataSeries CloseDown { get; set; }

        [Output("Low", LineColor = "Aqua")]
        public IndicatorDataSeries Low { get; set; }

        public MarketSeries dataseries;
        // public Bars dataseries;

        protected override void Initialize()
        {

            dataseries = MarketData.GetSeries(Symbol, AnotherTimeFrame);
            // dataseries = MarketData.GetBars(Symbol, AnotherTimeFrame);
        }

        public override void Calculate(int index)
        {
            // Top[index] = MarketSeries.High.Maximum(PeriodsHigh);
            //Bottom[index] = MarketSeries.Low.Minimum(PeriodsLow);

            High[index] = dataseries.High.Maximum(Period);
            //High[index] = dataseries.Bars.HighPrices.Maximum(Period);

            CloseUp[index] = dataseries.Close.Maximum(Period);
            CloseDown[index] = dataseries.Close.Minimum(Period);
            Low[index] = dataseries.Low.Minimum(Period);
        }
    }
}

I'm getting warnings:

For example if I change 

public MarketSeries dataseries;

to

 public Bars dataseries;

as the instruction says, I get an error:

Sorry to trouble with a similar issue, but I believe I'm not alone here with these 3.7 API substitution troubles...?

Hi Jani,

You do the substitution but you do not change the line below to

 dataseries = MarketData.GetSeries(Symbol, AnotherTimeFrame);

to 

dataseries = MarketData.GetBars(AnotherTimeFrame, Symbol.Name);

Here is the updated code

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


namespace cAlgo.Indicators
{

    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class HighestHighLowestLow2 : Indicator
    {

        [Parameter(" Period", DefaultValue = 10, MinValue = 1)]
        public int Period { get; set; }

        [Parameter(" Timeframe")]
        public TimeFrame AnotherTimeFrame { get; set; }

        [Output("Close Up", LineColor = "Red")]
        public IndicatorDataSeries CloseUp { get; set; }

        [Output("High", LineColor = "Pink")]
        public IndicatorDataSeries High { get; set; }

        [Output("Close Down", LineColor = "Blue")]
        public IndicatorDataSeries CloseDown { get; set; }

        [Output("Low", LineColor = "Aqua")]
        public IndicatorDataSeries Low { get; set; }

        public Bars dataseries;
        // public Bars dataseries;

        protected override void Initialize()
        {

            dataseries = MarketData.GetBars(AnotherTimeFrame, Symbol.Name);
            // dataseries = MarketData.GetBars(Symbol, AnotherTimeFrame);
        }

        public override void Calculate(int index)
        {
            // Top[index] = MarketSeries.High.Maximum(PeriodsHigh);
            //Bottom[index] = MarketSeries.Low.Minimum(PeriodsLow);

            High[index] = dataseries.HighPrices.Maximum(Period);
            //High[index] = dataseries.Bars.HighPrices.Maximum(Period);

            CloseUp[index] = dataseries.ClosePrices.Maximum(Period);
            CloseDown[index] = dataseries.ClosePrices.Minimum(Period);
            Low[index] = dataseries.LowPrices.Minimum(Period);
        }
    }
}

Best Regards,

Panagiotis 

Join us on Telegram

Head of Community Management at cTrader