Why are my controls being reset when starting cBot instance on another symbol?
Why are my controls being reset when starting cBot instance on another symbol?
05 Apr 2024, 13:20
Hello! I'm writing a trader assistant to open and manage positions.
I have no issues running it on one symbol like EUR/USD.
However as soon I start another instance of my bot on another symbol like USD/JPY, the radio buttons state is reset on the previous symbol (EUR/USD).
In debug I can see that something triggers the OnUnchecked event but my code doesn't fire it. Could you please explain why that happens?
Are those two instances totally isolated from each other?
Replies
krsnv
08 Apr 2024, 10:59
( Updated at: 09 Apr 2024, 05:14 )
RE: Why are my controls being reset when starting cBot instance on another symbol?
PanagiotisCharalampous said:
Hi there,
Please share your code and exact steps to reproduce this problem.
Best regards,
Panagiotis
Hi! Here's the code example. I run it on USDJPY. You should see two radio buttons in the top left corner. The “Limit” one is checked by default.
Then I start my bot on another symbol (XAUUSD). Limit is also checked by default.
But if I go back to USDJPY I can see that the Limit radio button on the first bot instance is unchecked. As I mentioned in the above message, something triggers OnUnchecked event and when I debug, the stacktrace shows it's being done by external code, meaning it's not my code who calls for Uncheck.
using cAlgo.API;
namespace cAlgo.Robots;
[Robot(AccessRights = AccessRights.None)]
public class RadioButtonResetExample : Robot
{
protected override void OnStart()
{
var mainPanel = new StackPanel();
var limitRadioButton = new RadioButton
{
Text = "Limit",
IsChecked = true,
GroupName = "OrderType",
Margin = 10,
};
var marketRadioButton = new RadioButton
{
Text = "Market",
IsChecked = false,
GroupName = "OrderType",
Margin = 10,
};
mainPanel.AddChild(limitRadioButton);
mainPanel.AddChild(marketRadioButton);
Chart.AddControl(mainPanel);
}
}
@krsnv
krsnv
15 Apr 2024, 12:17
RE: Why are my controls being reset when starting cBot instance on another symbol?
PanagiotisCharalampous said:
Hi there,
Please share your code and exact steps to reproduce this problem.
Best regards,
Panagiotis
Hi, any ideas?
@krsnv
PanagiotisCharalampous
16 Apr 2024, 05:34
RE: RE: Why are my controls being reset when starting cBot instance on another symbol?
krsnv said:
PanagiotisCharalampous said:
Hi there,
Please share your code and exact steps to reproduce this problem.
Best regards,
Panagiotis
Hi, any ideas?
Hi there,
This happens because all the controls belong to the same group name. Try something like this
var limitRadioButton = new RadioButton
{
Text = "Limit",
IsChecked = true,
GroupName = "OrderType" + InstanceId,
Margin = 10,
};
Best regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
07 Apr 2024, 05:33
Hi there,
Please share your code and exact steps to reproduce this problem.
Best regards,
Panagiotis
@PanagiotisCharalampous