Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 AttiM, 02-14-2024, 05:20 PM
        11 responses
        184 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by fernandobr, Today, 09:11 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by timmbbo, Today, 08:59 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by KennyK, 05-29-2017, 02:02 AM
        2 responses
        1,281 views
        0 likes
        Last Post marcus2300  
        Started by itrader46, Today, 09:04 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X