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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        182 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        334 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        259 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        358 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        188 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X