how to print a bot stop reason
how to print a bot stop reason
10 Jun 2020, 03:23
hi guys i need some advice, working on a bot and in backtesting i have a problem, even if i'm in profit, and it seems that there are no errors and no errors are printed using protected override void OnError (Error error) { Print ("Error occured, error code:", error.Code); } is there a way to know the reasons for a stop of the robot in the back test?
thanks a lot best regards
Replies
giuseppealessiof
10 Jun 2020, 17:08
RE:
PanagiotisCharalampous said:
Hi giuseppealessiof,
You need to provide more details like the cBot code and baclktesting parameters and dates so that we can reproduce this behavior and advise accordingly.
Best Regards,
Panagiotis
ok thank you very much for the answer but what I would like to know most of all is if I can have the opportunity to meet a code that writes me on the screen why the bot stops
thanks a lot
@giuseppealessiof
firemyst
11 Jun 2020, 05:44
RE: RE:
giuseppealessiof said:
PanagiotisCharalampous said:
Hi giuseppealessiof,
You need to provide more details like the cBot code and baclktesting parameters and dates so that we can reproduce this behavior and advise accordingly.
Best Regards,
Panagiotis
ok thank you very much for the answer but what I would like to know most of all is if I can have the opportunity to meet a code that writes me on the screen why the bot stops
thanks a lot
@Panagiotis can confirm, but I don't believe there are any built in reasons or codes as to why a bot was stopped.
there is when a position is closed though.
When you assign a method to run when a positions closed event has happened, you can read the "args" parameter to get a reason.
Example:
private void Positions_Closed(PositionClosedEventArgs args)
{
Print("Position closed for reason {1}", args.Reason);
}
Otherwise, if you want to know a reason why a bot stopped, you'll have to put in all your own codes whereever you call the Stop() method. And then within the Stop method itself you'll have to check your codes to see which one occurred, or if one occurred that you either didn't account for or was beyond your control.
@firemyst
PanagiotisCharalampous
11 Jun 2020, 08:53
Hi giuseppealessiof,
The reasons that can cause a cBot to stop in backtesting are
1) You manually stop it pressing the Stop button
2) You call the Stop() somewhere in your code
3) An exception occurs.
4) Your account reaches 0 equity.
Points 3 and 4 are obvious from the log and chart respectively. If it is point 1 then you should know about it else check if point 2 is a valid reason anywhere in your code.
Best Regards,
Panagiotis
@PanagiotisCharalampous
giuseppealessiof
11 Jun 2020, 11:40
RE: RE: RE:thank you very much, very kind !!
firemyst said:
giuseppealessiof said:
PanagiotisCharalampous said:
Hi giuseppealessiof,
You need to provide more details like the cBot code and baclktesting parameters and dates so that we can reproduce this behavior and advise accordingly.
Best Regards,
Panagiotis
ok thank you very much for the answer but what I would like to know most of all is if I can have the opportunity to meet a code that writes me on the screen why the bot stops
thanks a lot
@Panagiotis can confirm, but I don't believe there are any built in reasons or codes as to why a bot was stopped.
there is when a position is closed though.
When you assign a method to run when a positions closed event has happened, you can read the "args" parameter to get a reason.
Example:
private void Positions_Closed(PositionClosedEventArgs args) { Print("Position closed for reason {1}", args.Reason); }
Otherwise, if you want to know a reason why a bot stopped, you'll have to put in all your own codes whereever you call the Stop() method. And then within the Stop method itself you'll have to check your codes to see which one occurred, or if one occurred that you either didn't account for or was beyond your control.
@giuseppealessiof
giuseppealessiof
11 Jun 2020, 11:40
thank you very much, very kind !!RE:
PanagiotisCharalampous said:
Hi giuseppealessiof,
The reasons that can cause a cBot to stop in backtesting are
1) You manually stop it pressing the Stop button
2) You call the Stop() somewhere in your code
3) An exception occurs.
4) Your account reaches 0 equity.
Points 3 and 4 are obvious from the log and chart respectively. If it is point 1 then you should know about it else check if point 2 is a valid reason anywhere in your code.
Best Regards,
Panagiotis
@giuseppealessiof
Shares4us
11 Jun 2020, 14:01
RE:
Maybe something like this:
private void StopBecause(string reason="unknown")
{
Chart.DrawStaticText("StopMsg", reason , VerticalAlignment.Center, HorizontalAlignment.Center, "FFFFFFFF");
Print("Stopped: ",reason);
this.Stop();
}
Use Like:
if(DateTime.Now.Hour==19) StopBecause("It is time for dinner.")
@Shares4us
PanagiotisCharalampous
10 Jun 2020, 08:34
Hi giuseppealessiof,
You need to provide more details like the cBot code and baclktesting parameters and dates so that we can reproduce this behavior and advise accordingly.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous