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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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
-
floyd084, you would need to run this in realtime or replay for seeing the intrabar updates offered via CalculateOnBarClose = false. As in backtesting and processing historical data parts this would always be 'true' as the intrabar formation would not be available.BertrandNinjaTrader Customer Service
-
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 royhagerman, Today, 04:30 AM
|
0 responses
1 view
0 likes
|
Last Post
by royhagerman
Today, 04:30 AM
|
||
Started by haas88, 03-21-2024, 02:22 AM
|
18 responses
208 views
0 likes
|
Last Post
by haas88
Today, 02:37 AM
|
||
Started by Board game geek, Today, 02:20 AM
|
0 responses
6 views
0 likes
|
Last Post Today, 02:20 AM | ||
Started by knighty6508, Today, 01:20 AM
|
2 responses
15 views
0 likes
|
Last Post
by knighty6508
Today, 02:13 AM
|
||
Started by franatas, Today, 01:53 AM
|
0 responses
5 views
0 likes
|
Last Post
by franatas
Today, 01:53 AM
|
Comment