I am really wanting to understand the flow and timing of how this works, including when each method, OnBarClose and OnEachTick is used.
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
Understanding Order Flow
Collapse
X
-
Understanding Order Flow
Is there a link which explains how NT goes about entering/cancelling orders that a strategy generates?
I am really wanting to understand the flow and timing of how this works, including when each method, OnBarClose and OnEachTick is used.Tags: None
-
Thank you for the links. Again, I am trying to understand the order that NT does everything once a strategy says conditions are currently true for placing an order.
If my strategy is set to Calculate.OnEachTick, does my description in the picture accurately show what is happening? If so, why do I never see an entry order attempted until the next bar actually opens even if the conditions for an entry are true on the current bar? Can/should the order be placed before the bar closes and thus is there waiting when the next bar does open?
Comment
-
Hello Trader_Mark,
Historical orders when a strategy enabled are going to appear exactly as if Calculate was set to OnBarClose.
When using backtesting the strategy will run exactly the same as if CalculateOnBarClose is set to true. This is true whenever the strategy runs on historical type data. The reason for this is because the only info known historically is the Bar open, High, Low and close and not all of the ticks that make up the bar. You can also get extremely misleading results if you are using a bar that changes shape such as renko bar type as the finished bar does not show the true range of price movement.
Please see Discrepancies: Real-Time vs Backtest section of our helpguide.
Adding a secondary data series of a smaller time duration would allow your strategy to enter/exit intra bar and give you results closer to market replay.
Please see Backtesting NinjaScript Strategies with an intrabar granularity for a reference example on how you’d set this up.
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 by
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
-
I never said anything about backtesting. I am running the strategy live. With Calculate.OnEachTick set, should the order(s) be placed even before the current bar closes?
Comment
-
Hello Trader_Mark,
When running the strategy on live data, with calculate on each tick set to true, should your conditions become true, an order would be sent on the current bar.
Please see the following section of our helpguide,
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_AlanP View PostWhen running the strategy on live data, with calculate on each tick set to true, should your conditions become true, an order would be sent on the current bar.
Yes, but what happens is the order gets cancelled as soon as the current bar closes - so no chance to get filled.
Remember, the order is placed on the current bar, I am wanting it to get filled or cancelled on the next bar.
To recap, it is a range bar chart, bars will be 1 point in range. The strategy places an order 1 tick above/below the bars maximum size, so it can't be filled on the current bar by design. I want the buy or sell stop order sitting there waiting when the next bar opens.
Comment
-
Hello Trader_Mark,
If you'd like a order placed 1 tick above or below the current bars high/low, then you should run the strategy with Calculate set to OnBarClose, and have your strategy logic refer to the previous bar.
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_AlanP View PostHello Trader_Mark,
If you'd like a order placed 1 tick above or below the current bars high/low, then you should run the strategy with Calculate set to OnBarClose, and have your strategy logic refer to the previous bar.
Please let us know if you need further assistance.
Comment
-
Hello Trader_Mark,
There may be other ways, you could use EnterLongStopMarket, using the syntax,
EnterLongStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName)
Then run the strategy with calculate on each tick, have the order submitted on the current bar, but prevent the order from being modified on the next bar, which would achieve what you're looking to do as well.
Or under the other approach, you could write logic to not submit the order if the stop price was not valid, thus preventing rejected orders.
Please let us know if you need further assistance.Alan P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by volIQ, 03-27-2024, 04:28 PM
|
3 responses
21 views
0 likes
|
Last Post
by RJay
Today, 05:41 AM
|
||
Started by Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
72 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
7 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
9 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
13 views
0 likes
|
Last Post Today, 02:00 AM |
Comment