Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to use a bool to switch on/off a line ??

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

    How to use a bool to switch on/off a line ??

    I use the same indicator on two charts, it displays both lines and DrawRegions, the drawing is a resource hog and i want to show those on only one chart. I'd like to have a bool choice in the Parameters Dialog and simply say true/false. Here's what i have so far, but no-workie...

    #region Variables
    private BoolSeries ShowLine;
    #endregion

    --------------------------------------------------
    protectedoverridevoid Initialize()
    {
    ShowLine = new BoolSeries(this);
    }

    -----------------------------------------
    protectedoverridevoid OnBarUpdate()
    {
    if(ShowLine == true) {
    MyLine.Set(myValue
    ); }
    }
    ------------------------------------------
    #region Properties
    [Description(
    "Turn ON or OFF Graphics")]
    [Category(
    "Parameters")]
    [Browsable(
    true)]
    [XmlIgnore()]
    public BoolSeries ShowLine
    {
    get { return showLine; }
    set { showLine = value; }
    }
    ----------------------------------------






    #2
    Hello,

    See below. Note caps are important here...

    Put this in variables:
    bool showit = false;
    Put this around your calculations and draw portion in your OnBarUpdate() block:
    if(showit)
    {
    //calc's and draw here
    }
    Put this in your Properties:
    [Description("Turns off draw")]
    [Category(
    "Parameters")]
    publicbool Showit
    {
    get { return showit; }
    set { showit = value; }
    }

    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks Ben !! (and i am sure grateful for the support forum)
      It works perfectly --- and you are SO RIGHT about caps being important, once coded exactly with the correct case-sensitive code, it works great.
      Wishing you all the best...

      Comment


        #4
        I think the main thing he was trying to show you was to use a bool instead of a bool series.
        eDanny
        NinjaTrader Ecosystem Vendor - Integrity Traders

        Comment

        Latest Posts

        Collapse

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