Calculate(int index) not called when using custom indicator in bot

Created at 11 Jul 2016, 16:41
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!
HU

huupie_heijntje

Joined 11.07.2016

Calculate(int index) not called when using custom indicator in bot
11 Jul 2016, 16:41


I have a custom indicator and bot. Let's call them proIndicator and proBot respectively.

When I overlay the proIndicator on a chart, everything works fine, but when I try to use proIndicator in proBot then the Calculate(int index) function is not called. I verify this by writing Print(index) as the first line of the function. What I can do is call the function explicitely from proBot either like this:

int index = 0;

OnBar()
{
    proIndicator.Calculate(index);

    {
        // buy/sell
    }
    index++
}

or

OnBar()
{
    proIndicator.Calculate(MarketSeries.OpenTime.GetIndexByTime(MarketSeries.OpenTime.LastValue));
    
    {
        // buy/sell
    }
}

But both result in a discrepency in the current time between the indicator and bot. 

Observations:

  • The Initialize() function of the indicator is being called properly though.
  • When I use other custom indicator and bot pairs (i.e. downloaded from these forums) the problem is not observed.

 

Is this a problem observed before?

ps. I rather not share my source code.


@huupie_heijntje
Replies

... Deleted by UFO ...

huupie_heijntje
12 Jul 2016, 11:17

So called once per time frame, right? Furthermore, I do not clearly see what you are trying to explain.


@huupie_heijntje