Changed: How to change input settings after initialization?
Posted: Apr 23 2024
Ok, this might seem a small thing, but I might want my study to be "intelligent" and change an input setting after the study is initialized. For instance, I am working out a way to save Input preferences so if I remove a study, I can reload them later, especially if there are different inputs for different symbols all using the same study.
Now, I notice that after changing the input variables, the on-chart list of settings does not change. See what I am referring to here: This is the toy code I am using to test this out. I am even trying two different methods of changing the value of the input property. (in StartCalc, one of them is commented out, but either will work) While both update the value, neither method shows the change on the chart.
How do I show this updated input value on the chart (replacing "default", in this case)?
The Output shows the expected changes:
Now, I notice that after changing the input variables, the on-chart list of settings does not change. See what I am referring to here: This is the toy code I am using to test this out. I am even trying two different methods of changing the value of the input property. (in StartCalc, one of them is commented out, but either will work) While both update the value, neither method shows the change on the chart.
How do I show this updated input value on the chart (replacing "default", in this case)?
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;
using System.Reflection;
namespace PowerLanguage.Strategy {
public class _TEST_updateinput : SignalObject {
public _TEST_updateinput(object _ctx):base(_ctx){
this_input = "default";
}
[Input]
public string this_input {get;set;}
protected override void Create() {
Output.Clear();
Output.WriteLine("Create() this_input: {0}", this_input);
}
protected override void StartCalc()
{
// PropertyInfo pi = this.GetType().GetProperty("this_input");
// pi.SetValue(this, "setvalue changed input", null);
this_input = "direct changed input";
Output.WriteLine("StartCalc() this_input: {0}", this_input);
}
bool notified = false; // so the output doesn't continue to write after the first change
protected override void CalcBar(){
if (this_input != "default")
{
if (notified == false)
{
Output.WriteLine("CalcBar() this_input: {0}", this_input);
notified = true;
}
}
}
}
}
Code: Select all
Create() this_input: default
StartCalc() this_input: direct changed input
CalcBar() this_input: direct changed input