Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Trail Stop update tick by tick while calculate on bar close
Collapse
X
-
Trail Stop update tick by tick while calculate on bar close
My strategy calculates on bar close and per the settrailstop() help, the trail stop should be calculated tick by tick. This is not happening though, the trail stop only updates when a new bar opens. How can I fix this through the wizard so the stop is calculated tick by tick?
Tags: None
-
Yes, it would calculate then at the end of the bar as well - the tick by tick just means how the trailing aspect works, i.e. the new trail stop level is found. If you want to update on each tick, you could work in CalculateOnBarClose = false and work your 'on bar close' logic in FirstTickOfBar - http://www.ninjatrader.com/support/f...ad.php?t=19387
Comment
-
To get strategy updates not intrabar, you would need to it to 'true', otherwise your OnBarUpdate() is called on each tick on realtime data, which is not what you seek.Originally posted by fredb987Bertrand - so if I wanted a strategy to close trailing stop orders in Live mode the same way as in backtesting, I would only have to change this to 'false', correct?
CalculateOnBarClose = false
I'm trying to avoid having my trailing stop triggered before the close of a Renko bar.
Comment
-
OK, I see. The problem I have, however, is that my code *looks* like it would only close a position at the start of a new bar, but watching it trading live, I observed a position closed on a trailing stop intrabar. Here's my code example:Originally posted by NinjaTrader_Bertrand View PostTo get strategy updates not intrabar, you would need to it to 'true', otherwise your OnBarUpdate() is called on each tick on realtime data, which is not what you seek.
protected override void Initialize()
{
Add(SMA(FastSMA));
Add(SMA(SlowSMA));
SetTrailStop("", CalculationMode.Ticks, TrailStop, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(SMA(FastSMA), SMA(SlowSMA), 1))
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (CrossBelow(SMA(FastSMA), SMA(SlowSMA), 1))
{
EnterShort(DefaultQuantity, "");
}
Any ideas? Thanks so much for your help.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment