Announcement

Collapse
No announcement yet.

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(Highs[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(Highs[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 rufat, Yesterday, 09:24 PM
                1 response
                15 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by TRADEONECLIC, Yesterday, 10:05 PM
                0 responses
                23 views
                0 likes
                Last Post TRADEONECLIC  
                Started by BrennanSalibrici, 12-17-2020, 11:55 PM
                3 responses
                45 views
                0 likes
                Last Post StealthM93  
                Started by coopgrafik, Yesterday, 07:56 PM
                0 responses
                9 views
                0 likes
                Last Post coopgrafik  
                Started by MisterGee, Yesterday, 07:55 PM
                0 responses
                8 views
                0 likes
                Last Post MisterGee  
                Working...
                X