Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Close at particular bar
Collapse
X
-
Close at particular bar
What coding do i need to close either a long or short position at the close of a particular bar such as the 11:00 Am bar?Tags: None
-
Originally posted by NinjaTrader_Ray View PostHi,
You can use the ToTime() method to compare the time of a bar. See the following Help Guide information.
http://www.ninjatrader-support.com/H...V6/ToTime.html
Tried this code, for closing out at 4:00PM but it doesn't work?
if (ToTime(Time[0]) == ToTime(16,0,0) )
{
ExitLongLimit(Bars.CurrentBid);
ExitShortLimit(Bars.CurrentAsk);
}
Comment
-
-
[quote=ceesvh;16266]Jlm,
I think you should try
if (ToTime(Time[0]) >= ToTime(16,0,0) )
It might be that a tick is received 1 second after 16:00 hours and at that moment barclose is calculated. Time has passed 16:00:00 and the condition is not met.
That sounds right.
Will try.
Thanks
Comment
-
[quote=Mike Winfrey;16268]This is what I use...
if (ToTime(Time[0]) >= 150000)) do something...
Mike
Sounds good.
Thanks
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
169 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
326 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
251 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
353 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
180 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|

Comment