cBot onStop() Not Triggered When Running in the Cloud

Created at 25 Sep 2024, 20:03
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!
AN

Anus+

Joined 25.09.2024

cBot onStop() Not Triggered When Running in the Cloud
25 Sep 2024, 20:03


Hi everyone,

I’m running my cBot in the cTrader Cloud, and I’ve noticed that the OnStop() method does not seem to be called when the cBot is stopped. This behavior doesn’t occur when I run the bot locally, as OnStop() is triggered as expected.

I was wondering if anyone else has experienced this issue or knows why this might be happening in the cloud environment? Here are some key details:

  • The cBot runs normally otherwise, but when I stop it manually, OnStop() is not executed.
  • There are no errors or exceptions that I can see in the logs.
  • The bot is not overly resource-intensive, and I’ve ensured that there are no blocking or long-running operations in the OnStop() method.

Does anyone know if there are specific limitations or nuances in how cBots are managed in the cloud, which could prevent OnStop() from being triggered? Is there a recommended workaround for this issue?

Any insights or suggestions would be greatly appreciated!

Thanks in advance!


@Anus+
Replies

PanagiotisCharalampous
26 Sep 2024, 05:18

Hi there,

This is by design. OnStop() is not called for cBots running on the cloud.

Best regards,

Panagiotis


@PanagiotisCharalampous

Anus+
26 Sep 2024, 05:30 ( Updated at: 26 Sep 2024, 09:14 )

RE: cBot onStop() Not Triggered When Running in the Cloud

Hi Panagiotis,

Thank you for your response!

Since OnStop() is not called for cBots running in the cloud, I was wondering how I can ensure proper cleanup when stopping the cBot. Specifically, I’d like to close any open positions and delete any pending orders that were created by the cBot before it stops.

Is there any recommended approach or workaround to handle this in the cloud environment? For example, is there a way to automatically trigger such cleanups when the cBot is stopped manually in the cloud?

Thanks again for your help!

Best regards,

Anus+


@Anus+

PanagiotisCharalampous
26 Sep 2024, 09:15

RE: RE: cBot onStop() Not Triggered When Running in the Cloud

Anus+ said: 

Hi Panagiotis,

Thank you for your response!

Since OnStop() is not called for cBots running in the cloud, I was wondering how I can ensure proper cleanup when stopping the cBot. Specifically, I’d like to close any open positions and delete any pending orders that were created by the cBot before it stops.

Is there any recommended approach or workaround to handle this in the cloud environment? For example, is there a way to automatically trigger such cleanups when the cBot is stopped manually in the cloud?

Thanks again for your help!

Best regards,

Anus+

Unfortunately there is no workaround at the moment. If your strategy depends on OnStop() method, then it is better not to execute it on the cloud but on your own VPS.


@PanagiotisCharalampous