Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Region on Chart

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

    Draw Region on Chart

    Hello I need help: I want to draw a channel medium Draw.Region in my chart. But I don't get any values in the channel. I don't get any errors either. I structured the code like this:

    protected override void OnStateChange()

    ...
    AddPlot(new Stroke(channelColor, 2), PlotStyle.Line, "highChannel");
    AddPlot(new Stroke(channelColor, 2), PlotStyle.Line, "lowChannel");

    highChannel = new Series<double>(this, MaximumBarsLookBack.Infinite);
    lowChannel = new Series<double>(this, MaximumBarsLookBack.Infinite);​
    ...


    protected override void OnBarUpdate()

    ... here is some math....

    Draw.Region(this, "ChannelRegion", CurrentBar, 0, highChannel, lowChannel, channelColor, channelColor, 50);


    i dont know what wrong... Maybe someone get some tipps.

    #2

    Comment


      #3
      Hello Lopat,

      Thank you for your post.

      I suggest adding some print statements for your math to make sure the values are calculated as expected, as well as some prints of the values for highChannel[0] and lowChannel[0] to verify that each series is holding the expected values. Each added plot will add a Series<double> to the Values collection, so you will want to double-check that you are assigning the plot values to the appropriate series. For more informaiotn:
      Please let me know if I may be of further assistance.

      Comment


        #4
        Thanks. I did some adjustment. Now i get the following Error:

        Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

        Somebody know how to solve this`?

        Comment


          #5
          Hello Lopat,

          Thank you for your reply.

          Based on that error message, you will likely need to add a check to make sure you have enough bars available before your script accesses the series. We have more information about this on the following help guide page:


          Please let me know if I may be of further assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          627 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          359 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          562 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          567 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X