Attached is a screenshot example. The colored red and green circles represent when my buy/sell signal is triggered. I'd like it to simulate the trade at that time or soon after. Thanks
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
Order fill resolution on high but not working?
Collapse
X
-
Order fill resolution on high but not working?
When I back test my strategy I can't get my orders to execute until the following bar closes after a trigger. This means when running my strategy on a 60 minute chart after the buy signal is triggered it waits until the close of the next bar to simulate the placed trade. I tried turning order fill resolution to high and set it to 1 minute but it is making no change. I thought it worked before so I don't know if I am missing something or doing something wrong now.
Attached is a screenshot example. The colored red and green circles represent when my buy/sell signal is triggered. I'd like it to simulate the trade at that time or soon after. Thanks1 PhotoTags: None
-
Hello jerblaster23,
Thank you for your post.
Are your entries based on indicator calculations? Or are they based solely on price movement? Can you give a code example of one of your entries that isn't working as you'd expect?
High order fill resolution will give you a secondary series for price data - but indicators will continue to calculate OnBarClose. This can often cause the strategy to have nearly identical behavior with High order fill as without, depending on what triggers your trades.
It sounds like most likely your best bet would be to add the secondary more granular data series within the script itself, and submit your orders and calculate your indicators based on that. You could even separate your logic so it only submits orders to and calculates indicators on the secondary series to only be used when State == State.Historical and then relies on real time data to control everything once State == State.Realtime.
Here's a link to an example of adding intrabar granularity to a script for backtesting:
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
-
My entries are based on indicator calculations. My strategy uses an indicator that runs on the primary chart a 60 min chart. It calculates on bar close and I need to keep that as is and want to have it execute using the 1 min chart after a buy/sell signal is triggered.
I added a second data series of 1 minute in the Strategy Builder, unlocked the code and changed my buy long code to in NinjaScript Editor to:
EnterLong(1, 1, "Long: 1min");
I got that from the example you suggested. Compiled and now the strategy own't enable. I have a feeling I missed something. Can you be a little more specific about what I need to do or what I'm missing. I am very new to coding.Last edited by jerblaster23; 01-08-2020, 04:01 PM.
Comment
-
Hello jerblaster23,
Thank you for your reply.
I'd suggest structuring it a bit differently: If you just use a bars in progress check, you can restrict certain code to only run if a specific bar series is processing.
Here's an example:
Code:protected override void OnBarUpdate() { // If we are processing the secondary series if (BarsInProgress == 1) { EnterLong(1,"Long: 1 Min"); } }
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
-
Here is what I originally had under protected override void OnBarUpdate()
Code:protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 3) return; // Set 1 if ( // Buy Trigger ((my triggers are here) && (my triggers are here) { Draw.Dot(this, @"" + Convert.ToString(CurrentBars[0]), true, 0, (High[0] + (5 * TickSize)) , Brushes.Green); EnterLong(Convert.ToInt32(DefaultQuantity), ""); } // Set 2 if ( // Sell Trigger ((my triggers are here) && (my triggers are here) { Draw.Dot(this, @"" + Convert.ToString(CurrentBars[0]), true, 0, (High[0] + (5 * TickSize)) , Brushes.Red); ExitLong(Convert.ToInt32(Position.Quantity), "", ""); } } } }
if (BarsInProgress == 1)
Thank youLast edited by jerblaster23; 01-08-2020, 05:38 PM.
Comment
-
Hello jerblaster23,
Thank you for your reply.
First, High Order Fill Resolution isn't meant to be used with multi-series strategies - you're essentially doing manually what it would do for you, plus some. Leave that off when you test this.
Next, here's what I would suggest:
Code:protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 3) return; if(BarsInProgress == 1) { // Set 1 if ( // Buy Trigger ((my triggers are here) && (my triggers are here) { Draw.Dot(this, @"" + Convert.ToString(CurrentBars[0]), true, 0, (High[0] + (5 * TickSize)) , Brushes.Green); EnterLong(Convert.ToInt32(DefaultQuantity), ""); } // Set 2 if ( // Sell Trigger ((my triggers are here) && (my triggers are here) { Draw.Dot(this, @"" + Convert.ToString(CurrentBars[0]), true, 0, (High[0] + (5 * TickSize)) , Brushes.Red); ExitLong(Convert.ToInt32(Position.Quantity), "", ""); } } } } }
Kate W.NinjaTrader Customer Service
Comment
-
I copy/pasted your code in for mine exactly, adding in my triggers. The strategy doesn't plot at all. I tried again substituting in EnterLong(1,"Long: 1 Min"); as discussed earlier. My chart still has the 1 min secondary data series added in though the Strategy Builder though I tried it without as well. I also tried adding a visual 1 min chart using the Data Series window when viewing the chart just to be sure. All attempts return the same result doesn't plot buy/sell signals or draw dot's. Any suggestions?
Comment
-
Hello jerblaster23,
Thank you for your reply.
Ah, that's my fault - I reverted a change I'd made to the code before posting and didn't notice my reversion also put back the check for which Bars are in progress - leaving this in will skip processing on the secondary data series.
Code:if (BarsInProgress != 0) return;
Please let us know if we may be of further assistance to you.
Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
147 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,282 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
Comment