Are parameters defined persistent?

Created at 10 Jun 2023, 23:52
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!
CE

cesaramorim.civil

Joined 13.02.2023

Are parameters defined persistent?
10 Jun 2023, 23:52


Dear,

 

It seems to me the parameters defined such as:

 

 [Parameter("intvalue", Group = "General", DefaultValue = 0)]
        public intvalue { get; set; }
 

Are persistent, everytime the onBar event starts, if something changed the "intvalue" to other than 0, it will remain 0.

With variables defined not as parameters, they seem to change as expected.

 

Am I wrong?


@cesaramorim.civil
Replies

Waxy
12 Jun 2023, 13:03

You can change the values of these parameters at runtime, this is why they have "set" accessors, you can change their values.

This Prints:
Hello World
Hello World2
 

using cAlgo.API;

namespace cAlgo.Robots;

[Robot(AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
    [Parameter(DefaultValue = "Hello world!")]
    public string Message { get; set; }

    protected override void OnStart()
    {
        Print(Message);
        
        Message += "2";
        
        Print(Message);
    }

}



 


@Waxy