Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

conditional activation of AddLines

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

    conditional activation of AddLines

    I am trying to add a line but conditionally to a bool flag named showLines
    class
    private bool showLines= true;
    private int value = 2;

    Configure
    if (showLines)
    {
    AddLine(Brushes.DarkGreen, +threshold, "Threshold");
    }

    it works but the grid of the properties does not show the lines and as result I cannot give the user the ability to change their shape or color.

    if I move them, the code, to SetDefaults:
    then I see them in the grid but I can no longer enable them or disable because the showLines value set by the user wouldn't be yet available (it is always true no matter what).

    Do you have an idea how to resolve this?
    Best
    G

    #2
    Hello giogio1,

    Thank you for your post.

    If your indicator or strategy dynamically adds plots/lines during State.Configure, the user will unfortunately not have an opportunity to select the plot or to set the plot or line configuration via the UI.

    As a workaround, you may use custom public Brush, Stroke, or PlotStyle properties which are accessible in State.SetDefaults and pass those values to AddPlot() or AddLine() during State.Configure.

    An example may be found near the end of this page:

    https://ninjatrader.com/support/help...t8/addplot.htm

    I'm attaching a simple example of this using AddPlot(), but the same concept would work for AddLine().

    Please let us know if we may be of further assistance to you.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    637 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    571 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X