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

Profit target one bar late

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

    Profit target one bar late

    I've been working on a strategy that has a profit target that will typically be hit on the entry bar. I am trying to keep the strategy simple. However, if I use high resolution order fill for development, my entries are always one bar later than they occur real life. If I use tick or second granularity with multi data, my profit targets are not registered until the following bar. Is there some language I'm overlooking to get an accurate backtest of this strategy? I currently have my stoploss and profit target in OnBarUpdate, but I have tried it in OnStateChange as well. Thank you.

    #2
    Hello zrobfrank,

    using high order fill resolution would be the correct way to get intrabar fills however you still may see orders submitted on the following bar due to how the overall backtest processes on bar close. I would suggest adding a print into the entry condition to confirm the bar time of when the condition is true, that would help to see if the fill is based on the backtest engine. Another way to explore this would be to run the strategy in realtime on the playback connection to see if it works as you originally intended.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I have been struggling with this for months. If real time doesn't work the same way backtesting does, despite any combination of things including granularity and tick replay, then how does one design or optimize a strategy with any faith it can perform? It seems like no matter how thorough I am with my logic, running it in playback or realtime does not act like what I've tested. I can accomodate the language for fills and exits after watching real time, but how the heck can I optimize?

      Comment


        #4
        Hello zrobfrank,

        That greatly depends on what you are doing in your logic. A backtest runs on bar close and uses historical data which is less granular than realtime. You can simulate more granular fills by submitting orders to a more granular secondary series. you can also simulate granular logic by executing your logic on a granular series like a 1 tick series. If your strategy relies on more complex situations that occur in realtime like using OnMarketData you can use tick replay however you may see differences from realtime processing.

        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,404 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        95 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        159 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X