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

Intrabar Price

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

    Intrabar Price

    Hi,

    I am having difficulty understanding exactly how intrabar data comes in. What I want to do is something like:

    if Price > previous bar high do something

    So if CalculateOnBarClose = true, I could write:

    if(CalculateOnBarClose)
    {
    if(Close[0] > High[-1])
    { .... }
    }

    But if CalculateBarOnClose = fase, how do I do this?
    I need to know how to access price on an intrabar basis. So far I have found the following possibilities but there are contradictions:

    1. I need to add a data seies and in this way add granularity
    2. I can use Bars.Instrument.MasterInstrument.FormatPrice(thisP rice)
    3. I can use Gui.Chart.ChartControl.FormatYValue(price)
    4. Time[0]

    Can someone please help me? I need to find a way to access price intrabar.
    Thank you very much.

    #2
    Hello Zeos,

    For bar indexing, you always want to use positive values. [0] refers to the most recent and the one prior to this is [1]. For help using [ ], see the following forum post:


    If you want to compare the most recent price to the previous bars high when COBC = false, this is done simply with:
    if (Close[0] > High[1])
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you Ryan,

      My apologies on the indexing with -1. It was a typo that slipped in but thank you for catching it.

      So if I am to understand this, Close[0] will always refer to the most recent price whether COBC is true or false. Is this correct?

      Comment


        #4
        So if I am to understand this, Close[0] will always refer to the most recent price whether COBC is true or false. Is this correct?
        No, that is only true when COBC = false. When COBC = true, then the values you're accessing refer to the last closed (finished) bar, not the most recent price.

        If you need access to the most recent price when COBC = true, you can work within OnMarketData() event handler:
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Got it. Thank you very much.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by philmg, Today, 12:55 PM
          0 responses
          2 views
          0 likes
          Last Post philmg
          by philmg
           
          Started by Russ Moreland, Today, 12:54 PM
          0 responses
          2 views
          0 likes
          Last Post Russ Moreland  
          Started by f.saeidi, Today, 12:14 PM
          2 responses
          5 views
          0 likes
          Last Post f.saeidi  
          Started by TradeForge, 04-19-2024, 02:09 AM
          2 responses
          28 views
          0 likes
          Last Post TradeForge  
          Started by aprilfool, 12-03-2022, 03:01 PM
          3 responses
          327 views
          0 likes
          Last Post NinjaTrader_Adrian  
          Working...
          X