Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tick Offsets not Calculated in Historic Data

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

    Tick Offsets not Calculated in Historic Data

    NT,

    Why are the tick offsets for buy and sell orders in the code below not computed on the chart for historic data?

    Also,

    Even though calculate on bar close is set to false, why is NT still calculating buy and sell orders on first tick of new bar? ( both historic and realtime data)

    Thanks,

    RJay

    ----------------------------------------------------------------------

    publicclass Atrend : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int plusBarRange = 4; // Default setting for PlusBarRange
    private int minusBarRange = -4; // Default setting for MinusBarRange
    // User defined variables (add any user defined variables below)
    #endregion
    ///<summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    ///</summary>


    protectedoverridevoid Initialize()

    {
    CalculateOnBarClose = false;
    }

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


    protectedoverridevoid OnBarUpdate()

    {

    // Condition set 1

    if (GetCurrentBid() > Close[1] + PlusBarRange * TickSize)

    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2

    if (GetCurrentAsk() < Close[1] + MinusBarRange * TickSize)

    {
    EnterShort(DefaultQuantity, "");
    }

    }
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    #2
    RJay,

    When you are on historical data it can only be processed as if CalculateOnBarClose = true. Data that is not streaming real-time data will always be processed as CalculateOnBarClose = true and as such all trades generated by a signal bar will be produced on the first tick of the next bar.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      RJay,

      When you are on historical data it can only be processed as if CalculateOnBarClose = true. Data that is not streaming real-time data will always be processed as CalculateOnBarClose = true and as such all trades generated by a signal bar will be produced on the first tick of the next bar.
      Am I understanding this correctly, Only CalculateOnBarClose data can be used for backtesting and chart historic data.
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        Not sure what you mean by "CalculateOnBarClose data". CalculateOnBarClose is a setting that determines how your strategy handles calculations. When backtesting and on historical chart data, this option is always used as if it were set to true. Whatever you choose has no bearing on historical data. It only influences the strategy in real-time streaming data.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          RJay,

          With all due respect, no where did I say "CalculateOnBarClose data". As stated, CalculateOnBarClose is a setting that influences how real-time data is processed. On historical data you are always processing at the end of each bar and all orders will be placed at the first tick of the next bar which is the next available trading spot. Just because you have a chart open while connected to a data provider does not mean you are looking at real-time data. Only streaming data is considered real-time data. All data loaded onto a chart prior to that is historical data. A backtest also consists of all historical data.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            All I was hoping for was answers to two questions in the first post.

            1. "Even though calculate on bar close is set to false, why is NT still calculating buy and sell orders on first tick of new bar? ( both historic and realtime data)"

            2. "Why are the tick offsets for buy and sell orders in the code below not computed on the chart for historic data?"
            RJay
            NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

            Comment


              #7
              rt6176,

              1. You likely were not actually looking at real-time data. If you want to know how this works a very easy way to do this is just to use Print(Time[0].ToString()) in your code to see the timestamp of the bar being updated. When the bar is updating on real-time data you will get many prints of the same timestamp representing the same bar.

              2. Not sure how you have discerned that the tick offsets are not calculated. They are indeed calculated or else your strategy would not have placed any trades. What is important to note though is that GetCurrentBid/Ask() are real-time methods. When in backtesting they will just return you the close price of the bar.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Attached Is a capture to prove my RealTime feed by your definition.


                I have spent the last two weeks trying to get the NT order placement system to respond to my different strategies.

                All I keep getting is the "one trick pony".

                Orders are placed on first tick of new bar. Orders are placed at Chart price not Market.

                After 11 months of research and developement on NT's platform for a fully automated trading system, I have hit the "Wall".

                Attached Files
                RJay
                NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                Comment


                  #9
                  rt6176,

                  If you are using a 1 tick chart for sure it will trade on the next bar. To build your 1 tick bar the bar already closed. You can't trade on a closed bar.

                  This is not a wall by any means. This is the definition of a 1 tick chart. To receive the 1 tick of such a chart means the tick coming in closes the bar. It is impossible to trade on such a bar. If you received the tick, you are too late. Next tradeable location is open of next bar. In this instance, the open is also the close of that next bar.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    rt6176,

                    If you are using a 1 tick chart for sure it will trade on the next bar. To build your 1 tick bar the bar already closed. You can't trade on a closed bar.

                    This is not a wall by any means. This is the definition of a 1 tick chart. To receive the 1 tick of such a chart means the tick coming in closes the bar. It is impossible to trade on such a bar. If you received the tick, you are too late. Next tradeable location is open of next bar. In this instance, the open is also the close of that next bar.

                    NT,

                    I do not do any trading off any tick charts.

                    The only reason I posted the 1 tick chart was becouse you said I couldn't tell the difference between historic and real-time data feeds.

                    " 1. You likely were not actually looking at real-time data. "

                    -----------------------------------------------------------------------

                    You are also right that I would have to be a complete idiot to try to intra bar trade on a 1 tick bar chart.

                    "This is the definition of a 1 tick chart. To receive the 1 tick of such a chart means the tick coming in closes the bar. It is impossible to trade on such a bar."

                    LOLROG !!!!

                    Thank you for thinking that I would try to do that.

                    Maybe I should just become an onboard, in-flight, ballistic missile technician.

                    -----------------------------------------------------------------------

                    Well, I'm speechless!!!! Give yourself a raise. You've earned it.

                    I still have an order entry problem.

                    Another day with no solution,



                    Mmmmm.... Potato chips!!!!

                    RJay
                    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                    Comment


                      #11
                      RJay,

                      We have worked to try and resolve your issues. Whatever you post up is the only information we can base our analysis off of. You post a 1 tick chart and as such we think you are on a 1 tick chart.

                      Please follow my prior suggestion to figure out how it works. This is a fundamental concept that should be fully understood before attempting any use of strategies.

                      OnBarUpdate() with one line of code:
                      Print(Time[0].ToString());

                      You will see exactly how CalculateOnBarClose influences your strategy calculations. From there then you can add orders to see exactly when they are called.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      558 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      324 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      101 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      545 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      547 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X