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 SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
47 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
22 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
15 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
21 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
23 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|
Comment