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

Strategy Analyzer back test with stop loss and profit target orders

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

  • RedDuke
    replied
    Makes perfect sense, and I am totally fine with using single data series to be able to use Historical fill as High and Type as Minute. But how can I insert my logic (cancelling orders, submitting stop loss and etc) if this options is chosen on that granular level? When I use multi data series strategy, I can use BarsInProgress to control which series I am processing.

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello RedDuke,

    Thank you for your reply.

    High order fill resolution adds the more granular data series for you only if your strategy uses a single data series, so if you've added the data series manually and made sure the orders are correctly being placed to the 1 minute series like in the example from my previous post, and then tried to use the High fill resolution you'd get the error you've posted. You'd want to use it if you hadn't added that dataseries, but since you did you can use the standard order fill processing.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • RedDuke
    replied
    Hi Kate,

    Thanks for your response. It made things much clearer. I am still confused about back test option that I attached in my original post: Historical fill as High and Type as Minute. Does this option mean that strategy analyzer will drop to 1 min data series to simulate the fills? If I manually add 1 min data series, while using this option, I get the following error (see attached screen shot).

    My goal is to make sure that fills are simulated on 1 min bars when main chart is 60 or 120 min. This will get back test result as close to real market conditions as possible. The real market can navigate many times from low to high, and it is not visible when you just see 1 or 2 hour complete bar, where 1 min granular data will add a dose of reality.

    Thanks,
    redduke
    Attached Files

    Leave a comment:


  • NinjaTrader_Kate
    replied
    Hello redduke,

    Thank you for your post.

    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by submitting your orders to a more granular secondary bar series to achieve an "intrabar" fill in your backtests.

    I suggest you take a look at this example from our help guide:



    You should expect that a strategy running real-time (live brokerage account, live market simulation, Market Replay etc...) will produce different results than the performance results generated during a backtest. This difference may be more easily seen on certain Bars types (e.g. Point and Figure) than others due to their inherent nature in bar formation.

    During a backtest you can select different fill algorithms which will produce different results. Fills are determined based on 4 data points, OHLC of a bar since that is the only information that is known during a backtest and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

    Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick'.

    Also, here is a link to the differences on real-time vs backtest (historical).


    Adding intra-bar granularity as in the above sample can help with this.

    Intra-bar granularity adds a second data series such as a 1 tick series so that the strategy has finer granularity in the historical data in between the OHLC of the primary series. This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with.

    In NinjaTrader 8, there have been two new enhancements so that programmers do not have to manually add this secondary series and code the script to for high accuracy fills (Order Fill Resolution) and for intra-bar actions (TickReplay).

    Here is a link to our forums that goes into depth on using Order Fill Resolution and Tick Replay to ensure your backtests are as close to real time results as possible:

    https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/100192-comparing-real-time-historical-and-replay-performance?t=102504

    High Fill Order Resolution and TickReplay cannot be used together. If it is necessary to have both, it is still possible to add intra-bar granularity to a script in the code itself for order fill accuracy and use TickReplay to update indicators with Calculate set to OnPriceChange or OnEachTick historically.

    Please let us know if we may be of further assistance to you.

    Leave a comment:


  • Strategy Analyzer back test with stop loss and profit target orders

    Hello,

    Getting my head around Strategy Analyzer back-test and came across an issue. I can not figure out how to submit stop loss and profit target order during back test once my entry order gets filled.

    I choose Historical fill as High and Type as Minute (please see attached screen shot). The strategy trades off 1 hour bars, and submits a stop limit order to go long, for example, 10 ticks above current bar high. So if next bar hits this level the order gets executed and if not, my logic would cancel it on the following bar.

    I assume the option in screen shot tells strategy analyzer to go granular to 1 min intervals to check if my order gets hit, essentially 1 min bars represent how 1 hour bar was built. In real time when bar is being created with every ticks, the moment my stop limit gets executed and full quantity is filled, my logic will submit bracket order for stop loss and profit target. In order to so the same in strategy analyzer I need access to those 1 min intervals to know when order gets filled. How can I do it?

    Am I understanding how analyzer works correctly?

    Thanks,
    redduke
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by pmachiraju, 11-01-2023, 04:46 AM
8 responses
148 views
0 likes
Last Post rehmans
by rehmans
 
Started by mattbsea, Today, 05:44 PM
0 responses
5 views
0 likes
Last Post mattbsea  
Started by RideMe, 04-07-2024, 04:54 PM
6 responses
33 views
0 likes
Last Post RideMe
by RideMe
 
Started by tkaboris, Today, 05:13 PM
0 responses
5 views
0 likes
Last Post tkaboris  
Started by GussJ, 03-04-2020, 03:11 PM
16 responses
3,282 views
0 likes
Last Post Leafcutter  
Working...
X