Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy taking different trades in live vs backtest/historical

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

    Strategy taking different trades in live vs backtest/historical

    I'm testing out a very simple strategy to get the idea of how orders are submitted. My strategy uses/calculates OnBarClose and has a couple simple conditions. Very simple stuff such as if bar closes below a moving average, then place order. When I run a backtest, the orders looks OK. Same whenever I add it to a chart and look at the historical trades, everything looks fine. However, during live (sim) trading, the trades it placed do not fit any of the conditions. For example, the bar didn't close below the moving average but it still placed an order. In addition, as I understand it, if a market order were placed with OnBarClose, then it would likely fill at the open of the next bar. The historical data shows this but again on the live trades it took, the prices it entered on aren't near the open. The logs show that the order was initiated from the strategy. I understand that there would be discrepancies between historical and live but the fact that the trades were placed when it was simple conditionals that should have prevented it leaves me lost. Any thoughts would be appreciated. Thanks.

    #2
    Hello veetotheone,

    Are you printing the values to the output window so that we can confirm?

    If so, please save the output to a text file (right-click -> Save as) and attach this with your next post.

    If not, use prints and TraceOrders to understand behavior.

    Below is a link to a forum post that demonstrates using Print() to understand behavior and includes videos.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    80 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X