indicies randomly changing

Created at 05 Sep 2019, 03:25
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!
CA

calgodemo

Joined 28.05.2019

indicies randomly changing
05 Sep 2019, 03:25


Hi all,

 

I've coded a custom indicator, which I have properly integrated into my bot. The reference is there, and I am able to invoke the calculate method on every bar.

When debugging however, my indicies will suddenly change on me. One breakpoint the current index is 730, the next is 2198 or some other random number.

What is the cause of this? I think it's causing me some problems, I'll get the indicator drawing correctly and then in some totally random place it will draw again when none of the conditions are present. I'm thinking these indicies may have something to do with it????

Anyone else encountered something similar?

CaD


@calgodemo
Replies

calgodemo
05 Sep 2019, 07:56

Okay,

So, I am backtesting my bot and I have the indicator running so I can see what the bot is executing. If I close the indicator then I seem to not get the things confused, I'm curious why the indicator and bot while invoking the same code on the same marketdata somehow arrive at different values.

 

Is there a way for a bot to use a custom indicator and have the custom indicator viewable at the same time??? 

 

CaD


@calgodemo

PanagiotisCharalampous
05 Sep 2019, 09:05

Hi calgodemo,

Please post the indicator code and exact steps to reproduce this behavior.

Best Regards,

Panagiotis


@PanagiotisCharalampous

calgodemo
06 Sep 2019, 01:03

Panagiotis,

I don't have permissions to post the indicator code on this one, I apologize. Let me ask some more general questions and perhaps get to the bottom of it.

Can you or someone on the team explain to me 

  1. Can I have an instance of an indicator running on the same chart that a bot is invoking the indicator on?
  2. How does calgo handle the multithreading? When the bot invokes the calculate method and runs the same indicator code as the display instance should the values not be identical?
    1. Any known issues to cause this not to happen?
    2. Any known backtesting bugs that would not happen on forward testing?

I am running the standard calculate method on every tick for the robot, and in the indicator code I have the standard (index > lastindex) for onbar behavior.

If I do not invoke the code in the bot, the indicator tells me the right stuff, when I invoke with the bot I get something else. When the backtesting stops, the bot invoked indicator is erased from the chart and though it is the same code what remains from the separate instance is different. 

 

Appreciate your time, I will continue to examine on my end.

 

CaD


@calgodemo

PanagiotisCharalampous
09 Sep 2019, 10:06

Hi calgodemo,

  1. Yes you can but you need to add it manually. The instance on the chart is a different instance to the cBot one
  2. cTrader Automate is not thread safe thus does not support multithreading
    1. Backtesting sometimes skips some ticks for indicator calculation on the backesting chart. This can cause discrepancies between the indicator value shown on the chart and the indicator referenced inside the cBot. The correct one is the one referenced inside the cBot. To be able to detemine if this is the case we need the indicator code
    2. The above

Best Regards,

Panagiotis

 


@PanagiotisCharalampous