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

Visible Chart Price

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

    Visible Chart Price

    Hi guys,

    Is there a way I can call the lowest and highest price that's visible on my chart? To be clear it's the current high and low of prices that's visible in the panel.

    Thanks!

    #2
    Hello Bluebeep,

    For the visible bars only, likely the best way to accomplish this would be to use similar code to what OnRender or OnCalculateMinMax uses.




    The loop over the visible range of bars would essentially be the same in both cases, this could also be used from other areas like OnBarUpdate if necessary. The fundamental is the loop over the range of visible bars by using ChartBars.FromIndex and ChartBars.ToIndex.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you!

      Comment


        #4
        Sorry.... I'm trying to get this to work as well... I'm struggling with the Loop coding.. if anyone has any code they could paste in or another indicator example they can think of the cycle thru the bars that would be great.

        Comment


          #5
          Hello MattD888,

          Thank you for your post.

          From OnCalculateMinMax():

          Code:
          // For performance optimization, only loop through what is viewable on the chart
          for (int index = ChartBars.FromIndex; index <= ChartBars.ToIndex; index++)
          {
          // since using Close[0] is not guaranteed to be in sync
          // retrieve "Close" value at the current viewable range index
          double plotValue = Close.GetValueAt(index);
          
          // return min/max of close value
          tmpMin = Math.Min(tmpMin, plotValue);
          tmpMax = Math.Max(tmpMax, plotValue);
          }
          OnCalculateMinMax() and OnRender() both have code on their Help Guide pages demonstrating looping through the visible bars on the chart.

          It looks like the links from Jesse's initial post are broken so I'll repost them here.​

          https://ninjatrader.com/support/helpGuides/nt8/oncalculateminmax.htm​



          Please let us know if you have any further questions.
          Gaby V.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by TraderBCL, Today, 04:38 AM
          2 responses
          17 views
          0 likes
          Last Post TraderBCL  
          Started by martin70, 03-24-2023, 04:58 AM
          14 responses
          106 views
          0 likes
          Last Post martin70  
          Started by Radano, 06-10-2021, 01:40 AM
          19 responses
          609 views
          0 likes
          Last Post Radano
          by Radano
           
          Started by KenneGaray, Today, 03:48 AM
          0 responses
          5 views
          0 likes
          Last Post KenneGaray  
          Started by thanajo, 05-04-2021, 02:11 AM
          4 responses
          471 views
          0 likes
          Last Post tradingnasdaqprueba  
          Working...
          X