Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Calculate on each tick
Collapse
X
-
Calculate on each tick
Just a quick question regarding automated trading strategies. Does anyone have any experience using the calculate on each tick when buying and selling using profit targets? I've included a screenshot below of a Market Replay for the ES; if i set my profit as one tick above entry, occasionally i see this result. Is there any likelihood of this happening during live trading?
1 PhotoTags: None
-
Hello Renorail,
Thanks for your post.
I would suggest it is probable that will happen. Your strategy running Calculate.OnEachTick means your strategy code runs on each new tick and ticks can come in quite rapidly. If your code says to place an order, it will place an order. If on the next tick it still says to place an order it will place an order, etc, etc. When you send an order to the exchange, it will take longer than the length one tick in time for the order to be transmitted over the internet, received by the broker/exchange, placed in que, filled and acknowledged back to your strategy position. The order process is run in parallel to your code meaning that they are asynchronous events (incoming ticks fire OnbarUpdate() orders sent/received/filled/acknowledged).
You will want to control these processes with your logic now that you understand the asynchronous nature of orders to coding.
For example, if you wanted to only place one order per bar, you could use something like:
if (your entry conditions && CurrentBar != savedBar)
{
//entry order here
savedBar = CurrentBar; // save the number of the bar being processed to prevent re-entry on the same bar
}
In the above, you would need to create an int variable called savedBar. CurrentBar is the system bar counter: https://ninjatrader.com/support/help...currentbar.htm
Alternately you can work with OnExecutionUpdate(), OnPositionUpdate() and OnOrderUpdate() to get more involved with the synchronizing effort.
I would also suggesting reviewing the example strategy here if you wish to use these methods: https://ninjatrader.com/support/help...and_onexec.htm
If you would like your strategy created for you, we can provide references to 3rd party programmers.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
63 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
139 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment