Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Incorrect fills on backtests

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

    Incorrect fills on backtests

    Sorry for posting every other day but here's the most recent issue I'm facing. A quick brainstorming of what I could be doing wrong would suffice for now.

    I'm on NT 7.14. I have a strategy that enters limit orders at a certain price. The trades get executed at the correct limit price, however, they get executed at the wrong time. So basically price never touches the limit level and the trades gets executed. I'm attaching an image of a 1-tick chart produced during my backtesting. As you may notice, the fills are happening way outside of the price at the time. I've checked for wrong ticks and this behavior is seen on almost every trade produced by this strategy.

    I'm pasting below the simple strategy that I'm using where I see this behavior. I assume this is another one of NT's order entry quirks. If you've ever seen something like this before or may know what the issue is, then please do let me know.


    Code:
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
                
                Add(PeriodType.Tick, 1);
                Add(PeriodType.Minute, 5);
                TraceOrders = true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                if(Position.MarketPosition == MarketPosition.Long)
                {
                    if(BarsInProgress == 1)
                    {                
                        if(Close[0] >= (Position.AvgPrice + TickSize * 30))
                        {
                            ExitLong("longEntry");
                        }
                        else if(Close[0] <= (Position.AvgPrice - TickSize * 100))
                        {
                            ExitLong("longEntry");
                        }
                    }
                }            
                
                if(Position.MarketPosition == MarketPosition.Flat)
                {
                    if(BarsInProgress == 2)
                    {
                        if(Close[1] > Close[2])
                        {
                            EnterLongLimit(1, true, 100000, High[1], "longEntry");
                        }
                    }
                }            
            }
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by rexsole, Today, 08:39 AM
0 responses
1 view
0 likes
Last Post rexsole
by rexsole
 
Started by trilliantrader, Yesterday, 03:01 PM
3 responses
30 views
0 likes
Last Post NinjaTrader_Clayton  
Started by cmtjoancolmenero, Yesterday, 03:58 PM
4 responses
26 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by Brevo, Today, 01:45 AM
1 response
14 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by rjbtrade1, 11-30-2023, 04:38 PM
2 responses
74 views
0 likes
Last Post DavidHP
by DavidHP
 
Working...
X