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().
              BertrandNinjaTrader Customer Service

              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.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by mjairg, 07-20-2023, 11:57 PM
                    3 responses
                    213 views
                    1 like
                    Last Post PaulMohn  
                    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                    4 responses
                    544 views
                    0 likes
                    Last Post PaulMohn  
                    Started by GLFX005, Today, 03:23 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post GLFX005
                    by GLFX005
                     
                    Started by XXtrader, Yesterday, 11:30 PM
                    2 responses
                    12 views
                    0 likes
                    Last Post XXtrader  
                    Started by Waxavi, Today, 02:10 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Working...
                    X