protected override void Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, 8);
SetStopLoss("", CalculationMode.Ticks, 25, false);
CalculateOnBarClose = false;
IncludeCommission = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (Close[0] >= Bollinger(2.33, 8).Upper[0])
{
EnterShortLimit(DefaultQuantity, Bollinger(2.33, 8).Upper[0], "Short");
}
// Condition set 2
if (Close[0] <= Bollinger(2.33, 8.Lower[0])
{
EnterLongLimit(DefaultQuantity, Bollinger(2.33, 8).Lower[0], "Long");
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Simple Strategy Help
Collapse
X
-
Simple Strategy Help
So i run this strategy and even though I have onbarclose = false the strategy doesnt try to execute a trade until the bar closes. I haven't tried it real time but hte historical performance always shows executions on the open of the next bar, and not the current bar in which the "If Then" conditions where met. Any ideas?
Code:Tags: None
-
Hello,
When backtesting, events will always be processed at the end of the bar. For example if you are running on a 5 minute series, the events are processed at every 5 minute bar.
However, it is possible to add a smaller time frame to process events "intrabar". Please see our Reference Sample on 'Backtesting NinjaScript Strategies with an intrabar granularity'
You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this byMatthewNinjaTrader Product Management
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
668 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
377 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
110 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
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
580 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|
Comment