Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Real-Time Price Detection

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

    Real-Time Price Detection

    How do identify the current price to compare against say the SMA? If I wanted to do something like:

    IF Current price crosses below the SMA... [Do something]

    Right now in the price section I only see open close high low, but those are defined after a candlestick bar is done. I need to keep track of the price and compare in real-time.

    Please advise.

    #2
    Hello chaddweston,

    Thanks for your post and welcome to the NinjaTrader forums!

    If you want to see real time data then you would need to set your codes "calculate mode" to Calculate.OnEachTick. In this mode Close[0] IS the current price on the right edge as the bar forms and Close[1] is the close of the previously completed bar.

    One caution though is that if you check to see if the current tick has crossed the SMA you need to understand that on the next tick it could cross back and this could occur hundreds of times in the forming bar. So you would need to give some thought about how to deal with that. On the other hand, staying with Calculate.OnBarClose, Close[0] points to the last completed bar and it will not change on you...

    References: http://ninjatrader.com/support/helpG...?calculate.htm

    You can have your strategy run Calculate.OnEachTick and have some parts run once per bar and other parts run on each tick. Here is a link to a reference example that reviews and demonstrates how to do this: http://ninjatrader.com/support/forum...ad.php?t=19387
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by vantojo, Today, 01:39 PM
    0 responses
    15 views
    0 likes
    Last Post vantojo
    by vantojo
     
    Started by Rubens_2020, Today, 01:48 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by kempotrader, Today, 01:34 PM
    1 response
    23 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by bc24fl, Today, 01:50 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by bosajin, 01-21-2021, 09:15 AM
    7 responses
    59 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X