Use Panel to update BOT parameters/variables

Created at 11 Nov 2020, 12:55
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!
LI

lisabeaney

Joined 08.10.2019

Use Panel to update BOT parameters/variables
11 Nov 2020, 12:55


Hi,

I have a small on screen panel that I want to use to update the main BOT parameters.

This shows the BOT parameters

This is the on-screen panel

 private void ApplyAll()
            {
              

                var MaxSell = GetValueFromInput(SELLInputKey, 0);
                var MaxBuy= GetValueFromInput(BUYInputKey, 0);

                _robot.Print(string.Format("Update Parameters: Max SELL positions: {0}, Max BUY positions: {1}", MaxSell, MaxBuy));
                
              // Need to update BOT Parameters or variables here
            }

This is the code I'm using when the Apply Changes button is clicked. It works and write the values in to the log but whatever I try I can't get it to update the "main" BOT variables..... 

The panel is defined as - public class ParameterPanel : CustomControl and that is within public class TSGridBETA : Robot

Any help would be appreciated !

Lisa

 


@lisabeaney
Replies

PanagiotisCharalampous
11 Nov 2020, 13:51

Hi Lisa,

The parameter values displayed in the cBot parameters panel are not updated if they are changed from within the code.

Best Regards,

Panagiotis 

Join us on Telegram  


@PanagiotisCharalampous

lisabeaney
11 Nov 2020, 14:26

RE:

PanagiotisCharalampous said:

Hi Lisa,

The parameter values displayed in the cBot parameters panel are not updated if they are changed from within the code.

Best Regards,

Panagiotis 

Join us on Telegram  

Hi Panagiotis,

What I'm trying to do is set a variable based initially on the BOT parameter but then updated from the field in the Panel....

ie. take this parameter

        [Parameter("Max Buy Positions", Group = "Open Positions", DefaultValue = 8, MinValue = 0)]
        public double MaxOpenBuy { get; set; }

 public double iMaxBuy, iMaxSell;

Then, when the BOT starts :

 protected override void OnStart()
        {

iMaxBuy = MaxOpenBuy

}

and then have the iMaxBuy variable updated by the MaxBuy when the user clicks on the "Apply Changes" button.

I know its most probably a really simple thing I'm getting wrong or I've missed but I can't seem to get the iMaxBuy to update !

 

Many thanks,

Lisa


@lisabeaney

PanagiotisCharalampous
11 Nov 2020, 14:37

Hi Lisa,

In order to help you further, you need to provide me with the complete cBot code.

Best Regards,

Panagiotis 

Join us on Telegram  


@PanagiotisCharalampous

lisabeaney
11 Nov 2020, 14:44

RE:

PanagiotisCharalampous said:

Hi Lisa,

In order to help you further, you need to provide me with the complete cBot code.

Best Regards,

Panagiotis 

Join us on Telegram  

No problem, I'll email it through to you :)


@lisabeaney