Crashed in Calculate with NullReferenceException when referencing an indicator

Created at 27 Dec 2020, 22:23
AN

analogpermutations

Joined 27.12.2020

Crashed in Calculate with NullReferenceException when referencing an indicator
27 Dec 2020, 22:23


25/11/2020 00:06:40.291 | Crashed in Calculate with NullReferenceException: Object reference not set to an instance of an object.

I get the error above when trying to reference an indicator in a cBot

my code is 

private RelativeStrengthIndex rsi;

protected override void OnStart()
{
  rsi = Indicators.RelativeStrengthIndex(Source, RsiPeriod);
}

protected override void OnTick(){
   Print(rsi.Result.LastValue);
}

The Print fails, and crashes the bot with a null reference pointer.

What am I doing wrong??

Same thing is happening when trying to reference other timeframes as well.

 

 

Even if I just start a simple blank robot from scratch I get this error.

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        public DataSeries Source;
        BollingerBands bb;

        protected override void OnStart()
        {
            bb = Indicators.BollingerBands(Source, 14, 2, MovingAverageType.Simple);
        }

        protected override void OnTick()
        {
            // Put your core logic here
            Print(bb.Top.LastValue);
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 


@analogpermutations
Replies

analogpermutations
27 Dec 2020, 22:32

RE:

Figured it out.

Apparently 

public DataSeries Source;

has to be 

 

[Parameter("Source")]
public DataSeries Source { get; set; }

I feel like an idiot haha


@analogpermutations