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 Hwop38, 05-04-2026, 07:02 PM
                0 responses
                160 views
                0 likes
                Last Post Hwop38
                by Hwop38
                 
                Started by CaptainJack, 04-24-2026, 11:07 PM
                0 responses
                308 views
                0 likes
                Last Post CaptainJack  
                Started by Mindset, 04-21-2026, 06:46 AM
                0 responses
                245 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by M4ndoo, 04-20-2026, 05:21 PM
                0 responses
                349 views
                0 likes
                Last Post M4ndoo
                by M4ndoo
                 
                Started by M4ndoo, 04-19-2026, 05:54 PM
                0 responses
                179 views
                0 likes
                Last Post M4ndoo
                by M4ndoo
                 
                Working...
                X