// Condition to exit long
if (Close[0] < Close[1] || DateTime.Now.Ticks == 120000 || DateTime.Now.Ticks == 160000)
{
ExitLong();
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Exit Positions not working
Collapse
X
-
Exit Positions not working
I'm trying to figure out why my strategy isnt exiting my open positions when the time conditions are met. The close condition works, just not the time. I'm using a large renko bar for the strategy so rather than use ToTime(Time[0]) which sometimes would close me out an hour or more late due to the time stamp i figured Date.Time.Now.Ticks would work. My coding knowledge is very very limited so i have no clue if this is even right. I know i cannot backtest it, but running it live didnt work either.
Code:Tags: None
-
You would then need to look into separating your entry vs exit logic to work on the close of a bar and intrabar as desired - http://www.ninjatrader.com/support/f...ad.php?t=19387
A alternative would be adding another series, for example a 1 minute to the strategy to be able to access those timestamps via Times - http://www.ninjatrader.com/support/h.../nt7/times.htm
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
647 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
368 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
571 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment