Output variable from an indicator to a bot

Created at 20 May 2017, 19:45
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!
CR

croucrou

Joined 24.02.2016

Output variable from an indicator to a bot
20 May 2017, 19:45


Hello,

I am assigning a variable value to a public data series index within an indicator and output it.

It is printing out the value from the indicator, but from the bot it is printing out NaN.

The indicator is initialized correctly.

Please advise.


@croucrou
Replies

croucrou
24 May 2017, 14:36

Here is how I do that:

 

Indicator:

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class tl : Indicator
    {
       [Output("Result")]
       public IndicatorDataSeries Result { get; set; }

       public override void Calculate(int index)
        {
                Result[index] = variable;            
                Print(Result[index]); //Printing variable value correctly
                Print(Result[0]); //Printing NaN

                //alternatively:
                Result[0] = variable;
                Print(Result[0]); //Printing variable value correctly
               }
    }
}

 

Bot:

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class cBot : Robot
    {
        indicator ind;

        protected override void OnStart()
        {
            ind = Indicators.GetIndicator<indicator>();
        }

        protected override void OnTick()
        {
            Print(ind.Result[0]); //Printing NaN
        }
    }
}

 

Please help.


@croucrou

... Deleted by UFO ...