bot stops working after some time

Created at 10 Apr 2024, 19:14
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!
swingfish's avatar

swingfish

Joined 25.06.2016

bot stops working after some time
10 Apr 2024, 19:14


i have a bot that monitors my trades, messures Real/true drawdown and does some other things.

its quite complex because i'm bad in coding and it developed over the years.

 

i recently noticed that the bot stops working after some time, everything just stops. but the play button is still orange and nothing shows up in the journal/Automate tab.

is there a way to check on somthings like this.

 


@swingfish
Replies

PanagiotisCharalampous
11 Apr 2024, 05:38

Hi swingfish,

It's hard to tell with such vague information. But it's almost certain that it's some kind of a bug in your implementation. Maybe enhance your cBot with printing some information in the log so that you can understand what is actually stopping and where. Do OnTick() and OnBar() get triggered? Do your methods still get called? Does the code get blocked somewhere else?

Best regards,

Panagiotis


@PanagiotisCharalampous

swingfish
11 Apr 2024, 06:41

RE: bot stops working after some time

PanagiotisCharalampous said: 

Hi swingfish,

Do OnTick() and OnBar() get triggered? Do your methods still get called? Does the code get blocked somewhere else?

The bot uses both OnBar() and onTimer() but it's a choice i can make in a setting to make via a setting.

the bot does print a status text on the chart its deployed, and this does stop updating, so i guess the OnBar,OnTick and OnTimer are not called anymore.

when i stop the bot it takes much longer for it to stop, and when i start it again it does work just fine for some time.

and yes like you wrote it surely has somethings to do with my terrible code, i just don't know how to diagnose it.

it does write a file, calculates exposure and displays it, keeps profit/loss in a variable thats written to the filesystem.

it also has a feature to auto-hedge and other things, but all those things are disabled via settings and are never called.

i could add some printouts but those would create alot of log-traffic and the whole loop is running rather quickly as it really just writes the file OnBar only (this is to prevent too much harddisc traffic) and otherwise just recalculates the risk values based on realtime data such as equity/balance/and so on.


@swingfish

PanagiotisCharalampous
11 Apr 2024, 11:26

RE: RE: bot stops working after some time

swingfish said: 

PanagiotisCharalampous said: 

Hi swingfish,

Do OnTick() and OnBar() get triggered? Do your methods still get called? Does the code get blocked somewhere else?

The bot uses both OnBar() and onTimer() but it's a choice i can make in a setting to make via a setting.

the bot does print a status text on the chart its deployed, and this does stop updating, so i guess the OnBar,OnTick and OnTimer are not called anymore.

when i stop the bot it takes much longer for it to stop, and when i start it again it does work just fine for some time.

and yes like you wrote it surely has somethings to do with my terrible code, i just don't know how to diagnose it.

it does write a file, calculates exposure and displays it, keeps profit/loss in a variable thats written to the filesystem.

it also has a feature to auto-hedge and other things, but all those things are disabled via settings and are never called.

i could add some printouts but those would create alot of log-traffic and the whole loop is running rather quickly as it really just writes the file OnBar only (this is to prevent too much harddisc traffic) and otherwise just recalculates the risk values based on realtime data such as equity/balance/and so on.

Hi swingfish,

Any change it gets stuck in a loop or gets locked by waiting sore resource to be released e.g an open file? Just throwing ideas around since I have no idea about the specifics of your cBot.

Best regards,

Panagiotis


@PanagiotisCharalampous

swingfish
11 Apr 2024, 11:39

RE: RE: RE: bot stops working after some time

PanagiotisCharalampous said: 

swingfish said: 

PanagiotisCharalampous said: 

Hi swingfish,

Do OnTick() and OnBar() get triggered? Do your methods still get called? Does the code get blocked somewhere else?

The bot uses both OnBar() and onTimer() but it's a choice i can make in a setting to make via a setting.

the bot does print a status text on the chart its deployed, and this does stop updating, so i guess the OnBar,OnTick and OnTimer are not called anymore.

when i stop the bot it takes much longer for it to stop, and when i start it again it does work just fine for some time.

and yes like you wrote it surely has somethings to do with my terrible code, i just don't know how to diagnose it.

it does write a file, calculates exposure and displays it, keeps profit/loss in a variable thats written to the filesystem.

it also has a feature to auto-hedge and other things, but all those things are disabled via settings and are never called.

i could add some printouts but those would create alot of log-traffic and the whole loop is running rather quickly as it really just writes the file OnBar only (this is to prevent too much harddisc traffic) and otherwise just recalculates the risk values based on realtime data such as equity/balance/and so on.

Hi swingfish,

Any change it gets stuck in a loop or gets locked by waiting sore resource to be released e.g an open file? Just throwing ideas around since I have no idea about the specifics of your cBot.

Best regards,

Panagiotis

i can send it to you if you want to see the worst code written in ctrader history ;) 

 


@swingfish