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

Profitable strategy in backtest getting always hitting stop loss before profit target

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

    Profitable strategy in backtest getting always hitting stop loss before profit target

    I have a strategy in the works where is is looking for a small scalp while trading the ES market.

    When the right conditions are met, it simply looks for a profit of 5 ticks. Strategy Analyzer determined that the best results were yielded when the Stop Loss was set to 8 ticks.

    I've now tested the strategy settings on a playback connection, and it's giving me ~20% win rate rather than the ~80% win rate the back test showed. The problem is that the bar does fill the profit target, but most of the time a little later on into the bar.

    Can this be solved by switching the Strategy to an Calculate.OnPriceChange method instead of OnBarClose?

    My first idea was just to increase the stop loss. This fixed some of the bars, but then the the result of the strategy remains a loss because of the now larger stop loss.


    #2
    Hello torch2k,

    Thank you for writing in.

    You should expect that a strategy running real-time (live brokerage account, live market simulation, Playback connection etc...) will produce different results than the performance results generated during a backtest.

    When using Historical data, Strategies can ONLY be processed at the close of each bar. The fill price of an order is based on the OHLC of a bar and the price of the order itself since that is the only information that is known during a backtest.

    When using real-time market data or Playback you have a choice to run a strategy tick by tick (Calculate set to 'On Each Tick') which could produce different results. The fill price is based on incoming market data and volume, and you may receive better or worse fill prices depending on where the bid or ask price is and what volume is available at this market prices. During real-time live brokerage trading, orders are filled according to market dynamics.

    This is why you may see orders NOT fill in real-time that you may otherwise expect to see filled based on your backtesting results.

    Here is a NinjaTrader Help Guide link with information about discrepancies between realtime and historical data — https://ninjatrader.com/support/help...ime_vs_bac.htm

    Please let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DanielTynera, Today, 01:14 AM
    0 responses
    2 views
    0 likes
    Last Post DanielTynera  
    Started by yertle, 04-18-2024, 08:38 AM
    9 responses
    40 views
    0 likes
    Last Post yertle
    by yertle
     
    Started by techgetgame, Yesterday, 11:42 PM
    0 responses
    12 views
    0 likes
    Last Post techgetgame  
    Started by sephichapdson, Yesterday, 11:36 PM
    0 responses
    2 views
    0 likes
    Last Post sephichapdson  
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,615 views
    0 likes
    Last Post aligator  
    Working...
    X