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

Constant line(MIN(BB bandwidth, period))

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

    Constant line(MIN(BB bandwidth, period))

    With my limited programming skills I'm trying to plot the minimum value of an indicator looking back n periods. I would like that value as a constant line. Any ideas? Tried to modify the constant line indicator without any success. Shouldn't be too difficult, or?

    #2
    Precisely, do you get any errors in your code or as you apply the script? Did you add an index to the MIN method to return a double value and not a dataseries?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Oh, I get a lot of errors I'm afraid... I think the core issue though is what you suggest; to index the MIN method. But how do i do that? Using the private double method, or? I'd really appreciate if you could give me an example then I can fiddle with it a bit more.

      Comment


        #4
        MIN(some parameters)[0]

        The red index tells the code to use the latest min value as seen on the most current bar.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thank you both for your replies. I'm almost there now, but it doesn't exactly do what I want. Here is the code:

          #region Variables

          privateint minperiod = 100;

          #endregion

          protectedoverridevoid Initialize()
          {
          Add(
          new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
          CalculateOnBarClose =
          true;
          Overlay =
          false;
          PriceTypeSupported =
          false;
          }

          protectedoverridevoid OnBarUpdate()
          {
          double minimum = MIN(Bollingerbandwidth(2,14), minperiod)[0];
          Plot0.Set(minimum);

          Please take a look at this picture I uploaded: http://www.pixbox.se/pic_show_id29954163.html If you look at the 2nd last panel you'll see the "constant" minimum value plotted. You see that there is a drop in the last values. Why is that? It is set on exclude weekends and calculate on bar close: false.

          Comment


            #6
            Please open the called Bollingerbandwidth script and remove any CalculateOnBarClose reference from the Initialize() - then recompile, and reload the indicator you created fresh by pressing F5 on the chart. Does the value stay stable now?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Sweet. Yes they do. Thx!

              Comment


                #8
                Well, it appears it doesn't really do what I want it to do (se the simple code below).

                I would like it to take the minimum value of Bollingerband n days back (including checking the latest close) and plot that value as a constant line (for all days), like a support line.

                protectedoverridevoid OnBarUpdate()
                {
                double minimum = MIN(Bollingerbandwidth(2,18), minperiod)[0];
                Plot0.Set(minimum);
                }

                Possible?

                Comment


                  #9
                  Precisely, it seems like you would need to higher then a higher lookback setting for the MIN() method to incorporate more bars back into creating those support / resistance levels.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    I'm only interested in the minimum for the last 100 days or so, but it works as it is, simply not a beautiful solution. But I guess creating a constant line gets too complicated for me anyways. Thanks for your reply.

                    Comment


                      #11
                      You're welcome, then use just DrawLine() in the indicator and no unique tagID > thus you always modify the one plotted line in value and thus might look cleaner for your current evaluation.

                      BertrandNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by habeebft, Today, 07:27 AM
                      1 response
                      11 views
                      0 likes
                      Last Post NinjaTrader_ChristopherS  
                      Started by AveryFlynn, Today, 04:57 AM
                      1 response
                      12 views
                      0 likes
                      Last Post NinjaTrader_Erick  
                      Started by Max238, Today, 01:28 AM
                      4 responses
                      37 views
                      0 likes
                      Last Post Max238
                      by Max238
                       
                      Started by r68cervera, Today, 05:29 AM
                      1 response
                      10 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by geddyisodin, Today, 05:20 AM
                      1 response
                      14 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Working...
                      X