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

How to determine "fake" close price on Transition form Historical to RealTime?

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

    How to determine "fake" close price on Transition form Historical to RealTime?

    Hello.

    I figured out, that on transition form Historical to RealTime, CalculateOnBarClose() method run on non-completed bar.

    Close time and price on this non-completed are "fake": after bar completion it will have another close time and price.

    Method OnStateChange() with State == State.Transition calls after.

    So, is there any way to determine than OnBarUpdate() run on non-completed bar before (at) transition?
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Found thread with discussion of same question:
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    Comment


      #3
      Hello fx.practic,

      Thank you for your post.

      You could place a check for less than Realtime and the CurrentBar == ChartBars.Count-1 (which would be the last bar on the chart still building). For example:
      Code:
      if (State < State.Realtime && CurrentBar == ChartBars.Count -1) 
      {
      // your logic
      }
      Please let me know if you have any questions.
      Last edited by NinjaTrader_PatrickH; 12-05-2017, 11:04 AM.

      Comment


        #4
        Yahoo! Many thanks!!
        fx.practic
        NinjaTrader Ecosystem Vendor - fx.practic

        Comment


          #5
          Need same magic formula for NT7, please!
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment


            #6
            Hello fx.practic,

            Thank you for your response.

            You can use the Historical bool in NinjaTrader 7 in place of the Realtime State check. For example:
            Code:
            if (Historical && CurrentBar == Count-1)
            {
            //Process your code
            }
            Please let me know if you have any questions.

            Comment


              #7
              Thanks a lot for so fast response!

              Want to clarify: does this formula work in MTF scripts too?
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment


                #8
                Hello fx.practic,

                Thank you for your response.

                This will work for Multiple Series scripts. For example:

                NinjaTrader 7:
                Code:
                			if (Historical)
                			{
                				if (BarsInProgress == 0
                					&& CurrentBars[0] == BarsArray[0].Count - 1)
                				{
                					// Primary bar logic
                				}
                				
                				if (BarsInProgress == 1
                					&& CurrentBars[1] == BarsArray[1].Count - 1)
                				{
                					// Secondary bar logic
                				}
                			}
                NinjaTrader 8:
                Code:
                			if (State < State.Realtime)
                			{
                				if (BarsInProgress == 0
                					&& CurrentBars[0] == BarsArray[0].Count - 1)
                				{
                					//Primary bar logic.
                				}
                				
                				if (BarsInProgress == 1
                					&& CurrentBars[1] == BarsArray[1].Count - 1)
                				{
                					//Secondary bar logic.
                				}
                			}
                Please let me know if you have any questions.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by kaywai, 09-01-2023, 08:44 PM
                5 responses
                602 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                6 responses
                22 views
                0 likes
                Last Post xiinteractive  
                Started by Pattontje, Yesterday, 02:10 PM
                2 responses
                20 views
                0 likes
                Last Post Pattontje  
                Started by flybuzz, 04-21-2024, 04:07 PM
                17 responses
                230 views
                0 likes
                Last Post TradingLoss  
                Started by agclub, 04-21-2024, 08:57 PM
                3 responses
                17 views
                0 likes
                Last Post TradingLoss  
                Working...
                X