I've got a strategy running on a chart. I noticed that when I plot the executions that the executions are being plotted one-bar after the one I expect. Just wanted to check if this is normal or if there's a glitch in my code. I've attached a screenshot of an example. I expect to go long on the close of the bar before the entry bar thats plotted and exit on the bar before the exit bar that's plotted.
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
Plot Executions is on Wrong bar
Collapse
X
-
Plot Executions is on Wrong bar
I've got a strategy running on a chart. I noticed that when I plot the executions that the executions are being plotted one-bar after the one I expect. Just wanted to check if this is normal or if there's a glitch in my code. I've attached a screenshot of an example. I expect to go long on the close of the bar before the entry bar thats plotted and exit on the bar before the exit bar that's plotted.
1 PhotoTags: None
-
Hello kevinenergy,
Thanks for your post.
This behavior would be expected when we are calculating a strategy with Calculate.OnBarClose. Let's take a look at the SampleMACrossover strategy. A cross occurs and the next bar calculates the crossover and submits an order. The next bar after that then shows the execution marker.
Testing with Calculate.OnEachTick/OnPriceChange, we can see that a cross can occur, an order can be submitted and the execution can be plotted all on the same bar. I used Tick Replay to be able to run the strategy historically using Calculate.OnEachTick/OnPriceChange.
Please let us know if you have any additional questions.JimNinjaTrader Customer Service
- Likes 1
-
Thanks for clarifying Jim. Guess it makes sense since things are actually happening on the open of the next bar.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by rocketman7, Today, 02:12 AM
|
1 response
16 views
0 likes
|
Last Post Today, 07:38 AM | ||
Started by briansaul, Today, 05:31 AM
|
1 response
12 views
0 likes
|
Last Post Today, 07:36 AM | ||
Started by PaulMohn, Today, 03:49 AM
|
1 response
12 views
0 likes
|
Last Post Today, 07:36 AM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
6 responses
106 views
1 like
|
Last Post Today, 07:21 AM | ||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
6 responses
26 views
0 likes
|
Last Post Today, 07:18 AM |
Comment