// 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 CarlTrading, 03-31-2026, 09:41 PM
|
1 response
67 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
36 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
60 views
1 like
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
62 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
53 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment