What would happen if I set the entries per direction to 2?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Backtest data is different from live data
Collapse
X
-
overfills
Originally posted by NinjaTrader_Matthew View Post
What would happen if I set the entries per direction to 2?
-
Comment
-
I just checked the Time Stamp (time and sales) and this computers' internal clock is a full 8 seconds behind the time stamps from the data provider (CQG) ... would this be the reason for the overfill condition?
Comment
-
Update your system clock.Originally posted by JamieHendrix View PostI just checked the Time Stamp (time and sales) and this computers' internal clock is a full 8 seconds behind the time stamps from the data provider (CQG) ... would this be the reason for the overfill condition?
Double click the clock, look for internet time, change settings,
windows.com never appears to work, time-a.nist.gov looks like it worked
Comment
-
Yeah I got the time all worked out and it is right on with the time stamps coming from the broker. I guess I will know if this fixed the problem tomorrow morning..... Just wanted to know if anyone had any insight as to whether this discrepancy would cause my overfill problem.
Jamie Hendrix
Comment
-
Hello,
I dont believe it would resolve it as reading matts analysis below you have two orders in the market filling at the same time to get to an overfill. You say however that the stop loss and profit target are the only thing you submit however there is an issue here with the orders. If the time does not resolve please send us your code to support at ninjatrader dot com and reference this forum post. We can take a quick look at the code to see what might be the overfill condition and offer correct advice on that code.
-BrettBrettNinjaTrader Product Management
Comment
-
Here is a copy and paste of my code....
SetProfitTarget("", CalculationMode.Ticks, 1);
SetStopLoss("", CalculationMode.Ticks, 6, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Prevents the strategy from executing on historical data.
if (Historical)
return;
// Stops trading when a specified profit target has been reached.
if (Performance.AllTrades.TradesPerformance.Points.Cu mProfit >= 40)
return;
// Stops trading when a specified loss target has been reached.
if (Performance.AllTrades.TradesPerformance.Points.Cu mProfit <= -9)
return;
// Exits an open Long position 60 seconds before market close.
if (Position.MarketPosition == MarketPosition.Long
&& ToTime (Time [0]) >= 131400)
{
ExitLong();
}
// Exits an open Short position 60 seconds before market close.
if (Position.MarketPosition == MarketPosition.Short
&& ToTime (Time [0]) >= 131400)
{
ExitShort();
}
// Condition set 1
if ( Rising (SMA (14))
&& ToTime(Time[0]) >= 63000 && ToTime(Time[0]) <= 131000)
{
EnterLongLimit(1, Close [0] -1 *TickSize, "");
//PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert3.wav");
}
//if (Position.MarketPosition == MarketPosition.Long
// && Falling (SMA (14)))
//{
// ExitLong();
//}
// Condition set 2
if ( Falling (SMA (14))
&& ToTime(Time[0]) >= 63000 && ToTime(Time[0]) <= 131000)
{
EnterShortLimit(Close [0] +1 *TickSize, "");
//PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");
}
//if (Position.MarketPosition == MarketPosition.Short
// && Rising (SMA (14)))
//{
// ExitShort();
//}
// Plays alert when a profit target has been reached.
if (Performance.AllTrades.TradesPerformance.Points.Cu mProfit >=8)
{
PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\AutoBreakEven.wav");
}
Thanks for your help. Jamie Hendrix
Comment
-
Hello,
Thanks for supplying us with your code.
This is due to the limit order you have working near the market using SetProfitTarget("", CalculationMode.Ticks, 1);
What is occurring is when your exit signals are triggering, this profit target is very close to the market price which is causing both the exit and the profit target to fill around the same time.MatthewNinjaTrader Product Management
Comment
-
Matthew, I don't understand. When my entry is filled, I only have one working order to exit and that is the 1 tick "Profit Target" there are no other conflicting orders. The ExitLong and ExitShort are ignored with the "// "" I can delete those altogether, they are not used but the program should be ignoring them anyway.
Comment
-
Actually the condition sets are like this:
// Condition set 1
if ( Position.MarketPosition == MarketPosition.Flat
&& Rising (SMA (14))
&& ToTime(Time[0]) >= 63000 && ToTime(Time[0]) <= 131000)
{
EnterLongLimit(1, Close [0] -1 *TickSize, "");
//PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert3.wav");
}
//if (Position.MarketPosition == MarketPosition.Long
// && Close [0] < Position.AvgPrice -6 *TickSize)
//{
// ExitLong();
//}
// Condition set 2
if ( Position.MarketPosition == MarketPosition.flat
&& Falling (SMA (14))
&& ToTime(Time[0]) >= 63000 && ToTime(Time[0]) <= 131000)
{
EnterShortLimit(Close [0] +1 *TickSize, "");
//PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");
}
//if (Position.MarketPosition == MarketPosition.Short
// && Close [0] > Position.AvgPrice +6 *TickSize)
//{
// ExitShort();
//}
The condition of if marketposition is flat should tell it not to place the order unless the position is flat... if I am long , the short signal in condition 2 should be ignored because I am not "flat"..... AM I right?
Comment
-
Yes, if that is what is reflected in the OnBarUpdate event. However you should double check that this is where the account position actually is at this time. Since you're using COBC = true, the position will not be returned as flat/long/short until the next bar closes.MatthewNinjaTrader Product Management
Comment
-
OK. That makes more sense. I still don't understand why it only happens on one computer and not the other one but Oh Well anything that will fix the problem is fine with me.
So should I put the Position Flat statement in position update or order update or what? And would this solve the overfill problem?
Jamie Hendrix
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
68 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
41 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
24 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
27 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
53 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment