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

BarType as indicator parameter

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

    #16
    You will need to change this part of the code for the 12 range period type by adding the BarsArray[1] to the indicators MAX and MIN.
    Ok, so I'm a green horn!
    I've tried different ways to add the BarsArray[1]

    double hh = MAX(High(BarsArray[1]), nDay)[0];
    double hh = MAX(High[1][0], nDay)[0];

    and I get error messages in each attempt. Could you give me an example?

    Comment


      #17
      Originally posted by CaptainAmericaXX View Post
      Ok, so I'm a green horn!
      I've tried different ways to add the BarsArray[1]

      double hh = MAX(High(BarsArray[1]), nDay)[0];
      double hh = MAX(High[1][0], nDay)[0];

      and I get error messages in each attempt. Could you give me an example?
      Code:
      double hh = MAX(High[SIZE=3][COLOR=red][B]s[/B][/COLOR][/SIZE][1][0], nDay)[0];

      Comment


        #18
        Thanks for bearing with me. I tried that and now I get an error message that says, "can't convert a double to a data series". Any other way to do that?

        Comment


          #19
          Originally posted by CaptainAmericaXX View Post
          Thanks for bearing with me. I tried that and now I get an error message that says, "can't convert a double to a data series". Any other way to do that?
          Oops. I allowed myself to be misled by your code.

          Code:
          double hh = MAX(High[SIZE=3][COLOR=red][B]s[/B][/COLOR][/SIZE][1], nDay)[0];
          There should be no index on the Highs DataSeries.

          Comment


            #20
            Ok, thinking that perhaps there was something in the indicator code that was not allowing this to work I performed the same procedure on an SMA and I'm getting the same results. I'm obviously missing something in this equation. I simply want to project a 12 range SMA on a 4 range chart. What is missing in this code?

            Code:
            protected override void Initialize()
                    {
                        Add(new Plot(Color.FromKnownColor(KnownColor.Purple), PlotStyle.Line, "Plot0"));
                        Overlay                = true;
                        Plots[0].Pen.Width = 4;
                        Add(PeriodType.Range, 12);
                    }
                    protected override void OnBarUpdate()
                    {
                        if (BarsInProgress == 1)
            Plot0.Set(SMA(14)[0]);
                    }

            Comment


              #21
              Yea, I figured it out! Now to get it to work on my other indicator.

              if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
              return;
              Plot0.Set (SMA(BarsArray[1], 14)[0]) ;

              Comment


                #22
                Patrick, thanks for your help. I realized that the you gave me the answer several posts earlier. I just needed to study more to figure out what you were talking about. Keep up the good work!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by hurleydood, 09-12-2019, 10:45 AM
                14 responses
                1,093 views
                0 likes
                Last Post Board game geek  
                Started by cre8able, Yesterday, 04:16 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cre8able, Yesterday, 04:22 PM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by stafe, 04-15-2024, 08:34 PM
                5 responses
                28 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by StrongLikeBull, Yesterday, 04:05 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X