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

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.


      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.


          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.

          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by martin70, 03-24-2023, 04:58 AM
          15 responses
          114 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by The_Sec, Today, 02:29 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by jeronymite, 04-12-2024, 04:26 PM
          2 responses
          31 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by Mindset, 05-06-2023, 09:03 PM
          10 responses
          265 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by michi08, 10-05-2018, 09:31 AM
          5 responses
          743 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X