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

Can't apply indexing to a Double

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

    Can't apply indexing to a Double

    I'm working with the BollingerBand MACD indicator and want to apply some moving average filtering. To do this I need to work with dataseries data.

    I have started a new indicator and am building it from what I know to what I don't know.

    In the code attached, I can get the MACDStrength, Avg and SDev variables to calculate but am having problems with the upperBand variable.

    I get the "Cannot apply indexing with [] to an expression of type 'double'" message.

    I want "upperBand" to be a dataseries but don't know how to get there????

    Help please..
    taddypole...
    Attached Files

    #2
    Please try this:

    upperBand.Set(Avg[0]+(numStdDev*SDev[0]));

    Dan
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      Hi Taddypole,

      Your line here does not made logical sense...
      upperBand.Set(Avg+(numStdDev*SDev[0])[0]);

      breaking it down, you are trying to index the values...
      (numStdDev*SDev[0]) which is a double, not a data series

      Are you perhaps meaning to use....
      upperBand.Set(Avg[0] + numStdDev*SDev[0]);
      TimNinjaTrader Customer Service

      Comment


        #4
        yes..

        Thank you both, that is what i was trying to accomplish....

        taddypole....

        Comment


          #5
          Can someone tell me how to change the "DashStyle" of the Plot conditionally?

          In the attached code, on line 87 i've attempted some code but am getting errors.
          Attached Files

          Comment


            #6
            Unfortunately you could not change the style of the plot dynamically, you could just use a second plot with another style set in Initialize().
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Bertrand,

              Do you have an example of using a second Plot with another style set?

              I'm not sure if i understand how this would work.

              Also,

              What are the rules regarding multiple plots in an indicator and which ones are underneath and which ones are on top? Ive created an indicator with several plots and it appears that some of the plots that should be in the background are bleeding through and are covering up the plots that should be on top.

              I assume its the order of the Add plot statements in the "protected override void Initialize()" section.

              Regards,
              taddypole...

              Comment


                #8
                You can use Reset() to stop one plot while plotting another:

                if(x == y)
                {
                Values[0].Set(Close[0]); Values[1].Reset();
                }
                else
                {
                Values[1].Set(Close[0]); Values[0].Reset();
                }
                eDanny
                NinjaTrader Ecosystem Vendor - Integrity Traders

                Comment


                  #9
                  Hi Taddypole,

                  An example of setting to DashStyle can be found here: http://www.ninjatrader.com/support/f...ead.php?t=3228

                  Thought the main topic of that post is different it will give you a good example.
                  TimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pibrew, Today, 06:10 PM
                  1 response
                  16 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by actualfacts.2021, 07-25-2021, 03:11 PM
                  8 responses
                  1,182 views
                  0 likes
                  Last Post linkcou
                  by linkcou
                   
                  Started by reynoldsn, Today, 07:11 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post reynoldsn  
                  Started by needsomehelp147, 04-29-2024, 06:43 AM
                  2 responses
                  19 views
                  0 likes
                  Last Post needsomehelp147  
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  177 responses
                  2,400 views
                  0 likes
                  Last Post jeronymite  
                  Working...
                  X