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

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.
      Emily C.NinjaTrader Customer Service

      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.
          Emily C.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by needsomehelp147, 04-29-2024, 06:43 AM
          2 responses
          19 views
          0 likes
          Last Post needsomehelp147  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          177 responses
          2,400 views
          0 likes
          Last Post jeronymite  
          Started by algospoke, Today, 06:36 PM
          0 responses
          6 views
          0 likes
          Last Post algospoke  
          Started by ETFVoyageur, Yesterday, 06:05 PM
          8 responses
          53 views
          0 likes
          Last Post ETFVoyageur  
          Started by futtrader, 04-21-2024, 01:50 AM
          7 responses
          69 views
          0 likes
          Last Post NinjaTrader_Eduardo  
          Working...
          X