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

    Hello,

    I need to get the last traded price (tick by tick, not close price of the bar).

    I see there is a command for ask and bid, but not the last.

    I would need something like this:

    GetCurrentAsk(), or this: GetCurrentBid(), but for the Last traded price...

    Could you tell me if it is possible to get the last price?

    Thank You

    #2
    Hello,

    Thank you for the question.

    You could do this various different ways but it would depend on how the rest of your logic needs to work. You can utilize CalculateOnBarClose = false and then use Close[0]. Another way is to Add a 1 tick secondary series and utilize the Ticks close price. Also you can use OnMarketData and store the last price as a variable.

    All three of these items would have various effects on how the logic would be formed or how the script would perform. I would suggest to review the help guide on these individual concepts to find the one that works for what you want to do.







    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      It is very strange, but when I get Close[0] and Close[1] and print these, and then I see to the data on chart, there are not the same values. I'm using CL 01-17 instrument, and the chart show price data around 53 s while the Close [0] and Close [1] shows data around 50 s...

      Comment


        #4
        Hello,

        Thank you for the reply.

        Could you tell me what the specifics of the test were?

        What CalculateOnBarClose setting was the script using and also what timeframe was the script applied on? The specifics of the testing will matter on how the script is executed and what prices it can Print. Depending on where you are placing Prints you can affect the values seen as well.

        If you can provide the syntax for the test you were doing along with the settings used we can likely depict better what had occurred.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X