Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Backtest via Replay not entering orders
Collapse
X
-
"else if"
sampleMACrossOver
MyStrategyCode:[FONT=Courier New][SIZE=2][COLOR=#0000ff] protected[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate() { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (CrossAbove(SMA(Fast), SMA(Slow), [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])) EnterLong(); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (CrossBelow(SMA(Fast), SMA(Slow), [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])) EnterShort(); } [/SIZE][/FONT]
could it be the "else if" text that is preventing orders from being filled?Code:[FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate() { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Condition set 1 [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (sr1min([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]34[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]).UpTrade[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] == [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) { EnterLong(DefaultQuantity, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"go up !!!"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); } [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Condition set 2 [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (sr1min([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]34[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]5[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]).DownTrade[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] == -[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]) { EnterShort(DefaultQuantity, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"go down !!!"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); } [/SIZE][/FONT]
Comment
-
current or last swing
current high <= Swing "strength" (10).of current swinglow...
Code:[SIZE=2][FONT=Courier New](High[[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] <= Swing([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]10[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]).SwingLow[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]])[/SIZE][/FONT]
would the "last swing low" beCode:.SwingLow(1)
Comment
-
duck_CA,
You would need to debug your strategy. Please add Print functions inside your if-statements to see if they are even evaluating to true.
.SwingLow[1] is not the last low swing. It is the low swing's value as of the previous bar. You need to use this to get the barsAgo for the previous swing: Swing(int strength).SwingLowBar(int barsAgo, int instance, int lookBackPeriod)
And then you can plug that value into .SwingLow[].Josh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
72 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
44 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
25 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
30 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
61 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment