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 usazencort, Today, 01:16 AM
                0 responses
                1 view
                0 likes
                Last Post usazencort  
                Started by kaywai, 09-01-2023, 08:44 PM
                5 responses
                603 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                6 responses
                22 views
                0 likes
                Last Post xiinteractive  
                Started by Pattontje, Yesterday, 02:10 PM
                2 responses
                21 views
                0 likes
                Last Post Pattontje  
                Started by flybuzz, 04-21-2024, 04:07 PM
                17 responses
                230 views
                0 likes
                Last Post TradingLoss  
                Working...
                X