cBot stopping without reason

Created at 26 May 2020, 01:00
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!
BE

beneditobvn

Joined 26.03.2018

cBot stopping without reason
26 May 2020, 01:00


The backtesting in my cBot is not working as expected.

It should execute an order, wait for the position to close (position with TakeProfit and StopLoss), make some calculations and execute another order.

Inside OnTick, I have the calculations and the command to execute the order. Then inside OnPositionsClosed, I have one bool that allows the calculations to be done inside OnTick when the position is closed.

The following picture was taked from the Backtesting Log. It explains what should happen. The positions is closed, then it goes inside OnTick, do something (depending if was Profit or Loss), execute the other order and wait for the position to close.

But sometimes, it happens that after the order is executed and the postions is closed, it is calling OnStop first (I don't know why) and after that is calling OnPositionsClosed. And instead of going inside OnTick, the cBot stops. The the following picture.

How is it possible OnStop is being called just before the position is closed? Who is calling OnStop? Why is it been called at the time of the closing of the position?

I don't know if it is a mistake in the script or a bug in the backtesting function.

Please help.


@beneditobvn
Replies

PanagiotisCharalampous
26 May 2020, 08:20

Hi beneditobvn,

In order for somebody to help you, you need to provide the following.

1. The complete cBot code

2. cBot parameters and backtesting settings and dates that will allow us to reproduce this problem

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous