Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is wrong with this code?

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

    #16
    Hello Brandon, I tried the playback connection and i was able to successfully test the script. However, you also mentioned that i could run the strategy on a chart while connected to a real-time data feed connection.
    What do you mean by this?

    Running the script while the market is live or can i also enable the strategy on a chart and see how the trades might have taken on the previous days?
    When i tried the second approach, trades are only getting on bar close and NOT intrabar. How can i achieve the trades to be executed intrabar when i just enable the strategy on a chart and see how the trades might have taken on the previous days?

    Is it the same approach to write code to enable intradbar granularity as you explained here

    You would need to add intrabar granularity to your script and enable Tick Replay when running the backtest.

    See more about intra-bar granularity on the forum thread below.
    https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/94098-isfirsttickofbar-vs-onbarclose-for-backtest-live?p=773377#post773377
    This is your exact statement in one of your above reply "You may consider using the Playback Connection with Market Replay data to test and debug your strategy or run the strategy on a chart while connected to a real-time data feed connection."


    Comment


      #17
      Originally posted by NinjaTrader_BrandonH View Post
      Hello psangram,

      Thanks for your notes.

      You would need to add intrabar granularity to your script and enable Tick Replay when running the backtest.

      See more about intra-bar granularity on the forum thread below.
      https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/94098-isfirsttickofbar-vs-onbarclose-for-backtest-live?p=773377#post773377

      To do this, should i unlock the code and add additional code that is described in the video in the above article?
      And is this additional code only needed to backtest and not actually needed during the live trading during market open hours, right?

      Comment


        #18
        Hello psangram,

        Thanks for your notes.

        Testing the strategy on a chart while connected to a real-time data feed connection means that you could connect to your real-time data feed connections in the Connections menu, open a New > Chart window, enable the strategy on the Sim101 account that comes with NinjaTrader or a demo account if you have one, and watch the strategy run real-time to see how it performs.

        This would be how the strategy runs on real-time (live) data, not on historical data.

        To backtest the strategy on historical data you would need to add intrabar granualrity to your script as mentioned in post # 15. Yes, this requires unlocking the code from the Strategy Builder and manually programming your strategy to add a 1-tick data series and submit orders to that one tick series. Intrabar granularity cannot be added to a Strategy Builder strategy.

        Please reference the SampleIntrabarBacktest example and the following Help Guide links for more information.

        SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm

        TickReplay — https://ninjatrader.com/support/help...ick_replay.htm

        Developing for Tick Replay -
        https://ninjatrader.com/support/helpGuides/nt8/developing_for__tick_replay.htm?zoom_highlightsub= developing+for+tick+replay

        Additional information may be found in this NinjaTrader Forum post —
        https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/100192-comparing-real-time-historical-and-replay-performance?t=102504

        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X