Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy not executing on 15 minute bars
Collapse
X
-
Strategy not executing on 15 minute bars
I have a strategy that executes orders when using 1 min linebreak and 5 min linebreak bars. When running the strategy on 15 min linebreak bars, it refuses to execute any orders. I have used print statements inside the executing conditions which print at expected times, however, it does not enter any ordersTags: None
-
Hello samish18,
Thank you for your post.
Are there any errors in the Log tab of the Control Center?
Try testing the Sample MA Crossover strategy included with NinjaTrader on the same chart using the same instrument, bar type, interval, and date range.
Do you see results with the Sample MA Crossover strategy? (This would confirm for us data is available and the issue is with the logic in the custom script)
If the strategy is getting data and the strategy is enabled or a backtest is run with no errors in the Log tab of the Control Center, and the Sample MA Crossover is returning results, then would likely indicate the logic conditions in the custom strategy did not evaluate as true or orders are being ignored or cancelled.
In order to better understand how the code is working, it will be necessary to use Print to see how the conditions are evaluating and enable TraceOrders to see if orders are being submitted, ignored, rejected, or cancelled.
I'm also including a link to a forum post with further suggestions on debugging a script.
The prints should be outside of the conditions so we can see why the conditions are not evaluating as true.
Enable TraceOrders, print the time of the bar and all values used in the conditions that submit entry orders. Include labels for all values and comparison operators.
Let me know if you need any assistance creating a print or enabling TraceOrders.
Save the output from the output window to a text file and provide this with your reply.
I'll be happy to assist with analyzing the output.
Comment
-
There are no errors reported. Additionally, I have print statements within the conditions (next to the buy and sell functions) that execute, but the buy and sell do not. This indicates that the conditions are being evaluated as true, but for some reason orders are not submitted. Sample MA crossover works as expected and this strategy has been successfully implemented on 1 and 5 minute bars without this issue, however, the change to 15 minute bars seems to throw it off.
Comment
-
These are the prints from the strategy today:
7/23/2024 8:15:00 AMExit Short
7/23/2024 8:45:00 AMLong
7/23/2024 8:45:00 AMExit Short
7/23/2024 9:15:00 AMLong
7/23/2024 9:15:00 AMExit Short
7/23/2024 9:30:00 AMLong
7/23/2024 9:30:00 AMExit Short
7/23/2024 10:15:00 AMLong
7/23/2024 10:15:00 AMExit Short
7/23/2024 10:30:00 AMLong
7/23/2024 10:30:00 AMExit Short
7/23/2024 11:30:00 AMLong
7/23/2024 11:30:00 AMExit Short
7/23/2024 11:45:00 AMLong
7/23/2024 11:45:00 AMExit Short
7/23/2024 12:00:00 PMExit Long
7/23/2024 12:00:00 PMExit Short
7/23/2024 12:15:00 PMExit Long
7/23/2024 12:15:00 PMExit Short
7/23/2024 1:00:00 PMExit Long
7/23/2024 1:00:00 PMExit Short
7/23/2024 1:15:00 PMExit Long
7/23/2024 1:15:00 PMExit Short
7/23/2024 2:45:00 PMExit Long
7/23/2024 2:45:00 PMExit Short
7/23/2024 3:00:00 PMExit Long
7/23/2024 3:00:00 PMExit Short
The logic within onBarUpdate is as follows:
if (ema1[0] > ema2[0] && ema3[0] < ema4[0]) {EnterLong(4,1,"Long"); Print(Time[0] + "Long");}
if (ema1[0] <= ema2[0] || ema3[0] >= ema4[0]) {ExitLong(4,1,"Exit Long", "Long"); Print(Time[0] + "Exit Long");}
if (ema1[0] < ema2[0] && ema3[0] > ema4[0]) {EnterShort(4,1,"Short"); Print(Time[0] + "Short");}
if (ema1[0] >= ema2[0] || ema3[0] <= ema4[0]) {ExitShort(4,1,"Exit Short", "Short"); Print(Time[0] + "Exit Short");}
No executions occurred today
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
53 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
130 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
70 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
44 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment