// 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 charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
60 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
146 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
161 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
97 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
284 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|

Comment