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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    57 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    78 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    41 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    101 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    61 views
    0 likes
    Last Post PaulMohn  
    Working...
    X