Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LastPrice as variable in script of a Custom Indicator

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

    LastPrice as variable in script of a Custom Indicator

    Hello:

    What is the variable name NT uses for LastPrice? As it can be selected from the window (e.g., LastPrice > 0), I assume it is available to use in a custom indicator script for Market Analyzer? I have no problem using Open[0]. High[0], etc. in the custom script.

    Thanks.

    Tony

    #2
    Tony, you can use Close[0] (just like High[0], Low[0], etc) to get the last price.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Close[0] as LastPrice

      Hello Austin:

      Based on the help section, I assumed that Close[0] was the actual end price of a time frame for any instrument. Isn't this the case?

      Thanks.

      Comment


        #4
        Close[0] is always the last, current price, even before the bar closes. Dan
        eDanny
        NinjaTrader Ecosystem Vendor - Integrity Traders

        Comment


          #5
          tonyh, eDanny is absolutely correct. I can't put it any better so let me quote him: "Close[0] is always the last, current price, even before the bar closes."
          AustinNinjaTrader Customer Service

          Comment


            #6
            Close[0] = LastPrice

            Thanks Guys for the help. I assume that this is true even if CalculateOnBarClose is set to either true or false. Let me know if this assumption is incorrect.

            Comment


              #7
              tonyh, no it would still depend on the scripts CalculateOnBarClose setting, if you want to get the last tick, just use it on false and access Close[0].

              If you want to run and indicator on the close, but still need the last updated each tick, you could also 'grab' it from for example OnMarketData().

              Comment


                #8
                Close[0] = LastPrice

                Thanks for clearing it up Bertrand.

                Comment


                  #9
                  If in the Initialization region there is:

                  CalculateOnBarClose = true;

                  but then you have:

                  ///<summary>
                  /// Called on each bar update event (incoming tick)
                  ///</summary>

                  protected override void OnBarUpdate()

                  Close[0]

                  is this "Close[0]" the current (last tick) price or is it the bar close price?

                  Thx.

                  Comment


                    #10
                    It's not updated on each tick then, just responded to your other thread, you would need to use it in combo with setting COBC to false.

                    Then for 'end of bar' calcs you could still call them in if (FirstTickOfBar) context referencing one bar back further to achieve using both modes in the same strategy.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    111 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    59 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    38 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    41 views
                    0 likes
                    Last Post TheRealMorford  
                    Started by Mindset, 02-28-2026, 06:16 AM
                    0 responses
                    78 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Working...
                    X