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

Databox Price

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

    Databox Price

    Hello,

    I have a question regarding the Price in the Databox: I cannot identify where the value comes from. I am trying to access it from a share service. I have access to the ChartPanel, ChartControl, Bars, but the only thing I could find is ChartBars.LastPrice but it is only one value, I was expecting an array. I need to be able to go back to a specific bar and get its price value.

    Does someone know how I can access the price value of a specific bar from code?

    Thank you.

    Kind regards,
    Victor
    Attached Files

    #2
    Hello Devside_Victor,

    Thank you for your post.

    You could use Bars.GetClose, Bars.GetOpen, etc to get the OHLC values for a given bar index. To do so, you would need to loop through the rendered bars on the chart and then call something like Bars.GetClose(barIndex) to get the Close price at the selected bar index.

    See the help guide documentation below for examples and more information.
    Bars.GetClose - https://ninjatrader.com/support/help...8/getclose.htm
    Bars.GetOpen - https://ninjatrader.com/support/help...t8/getopen.htm
    Bars.GetHigh - https://ninjatrader.com/support/help...t8/gethigh.htm
    Bars.GetLow - https://ninjatrader.com/support/help...nt8/getlow.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hello Brandon,

      Thank you very much for your quick response.

      I can get the OHLC values without problems. My question was regarding the entry "Price" in the Databox (marked in yellow in attachment in the original post). Is there a way to get this value (or calculate if needed)?

      Thank you again.

      Kind regards

      Comment


        #4
        Hello Devside_Victor,

        Thank you for that clarification.

        Accessing the Data Box programmatically would not be possible. The Price value in the Data Box refers to the price where your cursor is. To get this value, you would need to use mouse coordinates and ChartScale.

        Please see the attached example script that demonstrates how this would be accomplished. Note that ChartPanel.MouseMove is subscribed when the State == State.DataLoaded and unsubscribed when State == State.Terminated. OnRender() captures ChartScale into a private property. ChartingExtensions.ConvertToVerticalPixels converts the coordinate to device pixels. MyChartScale.GetValueByY converts to a price.

        The output would be viewed in a New > NinjaScript Output window.

        Also, see the help guide documentation below for more information.

        ChartPanel - https://ninjatrader.com/support/help...chartpanel.htm
        OnRender() - https://ninjatrader.com/support/help...8/onrender.htm
        ChartScale - https://ninjatrader.com/support/help...chartscale.htm
        GetValueByY - https://ninjatrader.com/support/help...etvaluebyy.htm
        ChartingExtensions - https://ninjatrader.com/support/help...extensions.htm
        Working with pixel coordinates - https://ninjatrader.com/support/help...oordinates.htm


        Let us know if we may assist further.
        Attached Files
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by alifarahani, Today, 09:40 AM
        4 responses
        20 views
        0 likes
        Last Post alifarahani  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PhillT, Today, 02:16 PM
        2 responses
        7 views
        0 likes
        Last Post PhillT
        by PhillT
         
        Started by Kaledus, Today, 01:29 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frankthearm, Yesterday, 09:08 AM
        14 responses
        47 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X