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 trilliantrader, 04-18-2024, 08:16 AM
4 responses
18 views
0 likes
Last Post trilliantrader  
Started by mgco4you, Today, 09:46 PM
1 response
7 views
0 likes
Last Post NinjaTrader_Manfred  
Started by wzgy0920, Today, 09:53 PM
0 responses
9 views
0 likes
Last Post wzgy0920  
Started by Rapine Heihei, Today, 08:19 PM
1 response
10 views
0 likes
Last Post NinjaTrader_Manfred  
Started by Rapine Heihei, Today, 08:25 PM
0 responses
10 views
0 likes
Last Post Rapine Heihei  
Working...
X