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 Current Price

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

    Get Current Price

    I'm using renko bars and I don't get a visual of the current price. I wrote an indicator that displays horizontal lines for the bid and ask using GetBid and GetAsk functions. However, I would like to display a horizontal line for the current price. Using Close[0] doesn't work as it only applies to the renko bar data.

    Thanks,
    Mike

    #2
    Using Close[0] will work if you set your indicator to calculate intrabar.
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment


      #3
      calculateonbarclose is set to false and is working as it should for the bid and ask. however, because i am using renko bars, Close[0] only returns the closing price of the completed block.

      Comment


        #4
        Mike, I believe this is due to the programming of the custom renko bars type you use - this should be fixed with the renko bars type we'll add for NinjaTrader 7 - http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Well, I believe NT currently uses the Bid price for creating a chart, so you should be able to use GetCurrentBid() for the horizontal line.
          mrlogik
          NinjaTrader Ecosystem Vendor - Purelogik Trading

          Comment


            #6
            Thanks Bertrand...that may be true but I would still like to know how I can get the current price aside from using Close[0], if possible.

            Comment


              #7
              not so sure that's true MrLogik...i see many times when the spead is greater than 2 where the current price marker on the right of the chart is between the bid and ask which is why i am asking my question.

              Comment


                #8
                I asked this question a while back.

                The post is here
                mrlogik
                NinjaTrader Ecosystem Vendor - Purelogik Trading

                Comment


                  #9
                  This would also depend on the connection you use if I'm not mistaken - if you can't use Close, try using the last from OnMarketData() - http://www.ninjatrader-support.com/H...arketData.html
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    ah yes...thanks bertrand

                    Comment


                      #11
                      mrlogik...just read the thread and eventhough i fully understand the answer, it doesn't explain why the current price can and very often does appear between bid and ask.

                      Comment


                        #12
                        Bertrand,

                        Thanks for the suggestion. This works perfectly...Thanks again.


                        protectedoverridevoid OnMarketData(MarketDataEventArgs e)
                        {
                        if (e.MarketDataType == MarketDataType.Last)
                        DrawHorizontalLine(
                        "LastPrice",e.Price,Color.Black,DashStyle.Solid,1);
                        }


                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Shansen, 08-30-2019, 10:18 PM
                        24 responses
                        939 views
                        0 likes
                        Last Post spwizard  
                        Started by Max238, Today, 01:28 AM
                        0 responses
                        7 views
                        0 likes
                        Last Post Max238
                        by Max238
                         
                        Started by rocketman7, Today, 01:00 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post rocketman7  
                        Started by wzgy0920, 04-20-2024, 06:09 PM
                        2 responses
                        28 views
                        0 likes
                        Last Post wzgy0920  
                        Started by wzgy0920, 02-22-2024, 01:11 AM
                        5 responses
                        33 views
                        0 likes
                        Last Post wzgy0920  
                        Working...
                        X