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(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 Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                603 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                349 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                104 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                560 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                560 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X