Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic assignment / update of Plot properties

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dynamic assignment / update of Plot properties

    Support,

    Can you confirm this is not possible. I tried to assign the color of a plot using a string that I could change in the code and I got some system errors.

    Question #1

    In state set defaults I assigned the brush color to the string variable.

    BrushColor_1 = "Brushes.DimGray";

    In the plot code, I attempted to substitute the string but got errors... Is this just not possible?

    AddPlot(new Stroke (BrushColor_1, DashStyleHelper.Solid, 1,Opacity_03), PlotStyle.Line, Level_00_Label );

    Question #2

    It appears that once the plot names get assigned and the indicator is loaded, the only way to change the plot names displayed is to use the "reset template" option in the indicator dialog.

    Is there a way to do this using a bool option in the indicator and have the plot labels change based on the bool selected. I tried putting a set of strings in the State.configure code block thinking it would dynamically change the plot labels, but no luck.

    else if (State == State.Configure)
    {
    if (usePlotLabelOption2)
    {PlotString_01 = "testing label change";}​
    }​


    AddPlot(new Stroke (Brushes.Lime, DashStyleHelper.Solid, 1,Opacity_03), PlotStyle.Line, PlotString_01 );



    Any other options to have these plot names dynamically change without getting into the code and then resetting the template?

    Thanks

    #2
    Hello MattD888,

    A string is not the same as a Brush, that cannot be used interchangeably with AddPlot.If you want to type in a value rather than selecting a brush you would still use a Brush property, the brush selector by default lets you type in colors as hex codes.

    Regarding the name, you can change that dynamically from State.Configure. The AddPlot would move from SetDefaults to Configure in that use case.


    Code:
    public bool toggle {get;set;}
    protected override void OnStateChange()
    {
        if(State == State.Configure)
       {
          if(toggle)
             AddPlot(new Stroke(Brushes.Red), PlotStyle.Dot, "Test");
          else
             AddPlot(new Stroke(Brushes.Red), PlotStyle.Dot, "Test1");
       }
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    217 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    132 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    147 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    231 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    192 views
    0 likes
    Last Post CarlTrading  
    Working...
    X