• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get last price

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

    Get last price

    I feel like an idiot for posting this...

    What object/method do I use to get the last price? I don't want the last Close of the previous bar. I simply want the last agreed price within a bar.

    I am trying to use GetCurrentAsk/Bid but I'm not getting the results I want.

    What I'm trying to do is determine if the last price is greater than an indicator value one bar ago.

    Thanks!

    #2
    Hello StealthM93,

    Thanks for your post and welcome to the NinjaTrader forums!

    If you are using the Calculate mode of Calculate.OnBarClose then the value of Close[0] will represent the latest completed bars close and the currently forming bar is unknown until it closes.

    To get the "live" price, you would need to change the calculate mode to Calculate.OnEachTick. This will shift the bar references such that Close[0] will represent the current right edge price at any moment.

    Reference: http://ninjatrader.com/support/helpG...?calculate.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello NT_Paul,

      Perfect... Just want I was looking for. Thank you!
      I'd update the documentation to include this fact about tick data.
      http://ninjatrader.com/support/helpG...-us/?close.htm

      Kind regards!

      Comment


        #4
        Originally posted by NinjaTrader_PaulH View Post
        To get the "live" price, you would need to change the calculate mode to Calculate.OnEachTick. This will shift the bar references such that Close[0] will represent the current right edge price at any moment.
        Hi NT_PaulH,

        What if the current Type = Range? In this case, at the point OnBarUpdate() is called, by definition the price has changed, otherwise the bar wouldn't have updated. Is there any way to get the new open of the bar that just started?

        I'm doing Calculate.OnBarUpdate, (because I want Order fill resolution = High)

        Thanks!
        Last edited by buzzripper; 03-31-2019, 03:59 PM.

        Comment


          #5
          Hello buzzripper,

          For any bar type including range bars, if you want OnBarUpdate to trigger with the current bars price, you will need Calculate to be .OnEachTick or .OnPriceChange. This causes OnBarUpdate to trigger using the bars current Close price.

          If you want this price on the first tick of a new bar, you can have a condition that requires IsFirstTickOfBar to be true.
          https://ninjatrader.com/support/help...ttickofbar.htm

          You could also add a 1 tick series and get the price of every tick. You would need a bool or some sort of flag to know that the primary bar has closed.
          https://ninjatrader.com/support/help...dataseries.htm
          https://ninjatrader.com/support/foru...377#post773377
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by SAILIKITY, 05-22-2019, 05:41 PM
          1 response
          2 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by rmillar, 01-09-2019, 06:02 PM
          6 responses
          58 views
          1 like
          Last Post eDanny
          by eDanny
           
          Started by mlarocco, Today, 11:39 AM
          4 responses
          19 views
          0 likes
          Last Post mlarocco  
          Started by roblogic, Today, 11:19 AM
          2 responses
          14 views
          0 likes
          Last Post roblogic  
          Started by saeed, Today, 10:17 AM
          8 responses
          39 views
          0 likes
          Last Post NinjaTrader_Kate  
          Working...
          X