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!
See more
See less

Partner 728x90

Collapse

history backtest not filled intra-bar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    history backtest not filled intra-bar

    Hello everybody,

    I have made a custom strategy with strategy builder which opens a position when price reaches a horizontal indicator line. I did read a lot (incl. this great tutorial) about the filling process and the differences between historical, market replay, live but I'm still struggling in understanding why it doesn't work as I expect. When I enable the strategy on a 15min chart I see all the fills in history. They occur according "after bar closed" mechanism which I understand in general. The history data works only with OHLC, alright understood. When I switch to chart interval 1min I get the higher resolution and more realistic fills which are not perfect but pretty ok. But I want to look at an arbitrary higher time interval, for the sake of example 30min chart, and have the fills happen still at higher resolution 1min chart. That's why I used "high fill resolution at 1min" because this automagically adds a secondary data series in NT8 which can be used for the higher resolution fills independent of the current display view chart interval. But it's not working as I expected. Although I know that calculate mode "on price change" or "on each tick" affects only live or market replay data with level1+level2 information I tried following: the calculate mode is "on each tick" and I use "high fill resolution" at type=1min. However, the fills do not occur nearby horizontal indicator line where I should have expected (and which I cross-checked when manually switching to chart view 1min interval) but way higher because of the late bar close. The upcoming bar fills at the open price. Why does the high fill resolution not work, it seems I'm missing something important?

    Then I went to Tools --> Options --> MarketData and enabled the function "Show tick replay". This enables the checkbox [ ] TICK REPLAY in the menu of CTRL+F Data Series of a chart. I enable tick replay and choose Last price, type=tick, interval=1. In my humble understanding this is the smallest value and thus highest resolution possible. Of course I load only a few days of data not to overstress my computer . But again, it does not work as expected. My strategy now greys out the "high fill resolution" selection as stated in the documentation, that means tick replay seems to be active. But the fills still happen at bar close and thus not correct in high resolution.

    What I suspect is that it won't work with strategy builder but I need to unlock the code and manually code this somehow? any help appreciated.
    Last edited by patricia70; 12-16-2020, 03:09 AM.

    #2
    Hello patricia70,

    Thank you for your post.

    By default when backtesting no intra-bar granularity is added. To improve the accuracy of a backtest, you may use Tick Replay along with an added 1-tick series to have logic processed intra-bar and have orders filled intra-bar.

    Tick Replay would be used to have the logic process OnEachTick or OnPriceChange with historical data, but this does not allow for intra-bar order fills. You would need to add a single tick data series and submit orders to that single tick data series for a strategy that uses Tick Replay. This would require you to unlock your code from the Strategy Builder.

    High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.

    Please reference the SampleIntrabarBacktest example and the following help guide documentation for more information.

    SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm

    TickReplay - http://ninjatrader.com/support/helpG...ick_replay.htm

    Developing for Tick Replay - http://ninjatrader.com/support/helpG...ick_replay.htm

    Additional information may be found in this NinjaTrader Forum post —
    https://ninjatrader.com/support/foru...mance?t=102504

    Please let us know if we may be of further assistance.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi Brandon and thanks for coming back to my question.

      Originally posted by NinjaTrader_BrandonH View Post
      By default when backtesting no intra-bar granularity is added. To improve the accuracy of a backtest, you may use Tick Replay along with an added 1-tick series to have logic processed intra-bar and have orders filled intra-bar.

      Tick Replay would be used to have the logic process OnEachTick or OnPriceChange with historical data, but this does not allow for intra-bar order fills. You would need to add a single tick data series and submit orders to that single tick data series for a strategy that uses Tick Replay. This would require you to unlock your code from the Strategy Builder.
      I guess this is the issue I am facing. Although I use tick replay and calulcate="OnEachTick" my fills when entering a position are not accurate. I remembered to have red that NT8 automatically adds an additional tick data series behind the scenes when using high fill resolution and tick data. In NT7 we had to manually perform this step. Can you clarify, please?

      On the other side, I do not understand why entering a position is not accurate whereas exiting the position at my take-profit or stop-loss level always is 100% accurate? Why does NT8 perfectly exit my position in all cases I tried so far? Is it because the take-profit or stop-loss price level was set ago on each condition check? I am using the same technique as shown HERE by Kate.

      Originally posted by NinjaTrader_BrandonH View Post
      High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.
      I understand. But still I don't understand: what is the proper way to get as accurate (just like in real live market) fills when entering a position? Do I need to focus to Tick Replay or Using High Order Fill resolution?

      Originally posted by NinjaTrader_BrandonH View Post
      Please reference the SampleIntrabarBacktest example and the following help guide documentation for more information.
      Did so, many thanks. I watched the code and I see and understand the logic of the two existing data series and how to access them.

      Anyway, the help fiel at Developing for Tick Replay says:
      Notes:
      1.Tick Replay was NOT designed to provide accuracy in backtesting concerning order fills and execution and should NOT be used to expect the exact sequence of executions as running a strategy on live data. For greater order-fill resolution and accuracy in strategy backtesting, you can use the High Fill Resolution in the Strategy Analyzer. Furthermore you cannot combine both Tick Replay and High Order Fill resolution.
      So my question still is --> what is the better approach?

      1.) - enable Tools --> Options --> Market Data --> Show Tick Replay
      - press CTRL+F for DataSeries and enable Tick Replay
      - develop the strategy with Ninjascript editor by using the secondary data series and sending the entering position logic into barsinprogress==1
      - in strategy use Calculate=onEachTick

      -or-

      2.) - disable Tools --> Options --> Market Data --> Show Tick Replay
      - no need to develop with tick data as shown in 1)
      - in strategy use HighOrderFillResolution with time frame = 1min or even tick=1

      ??? I tried option 2) already but without success. That was my initial question.

      appreciate your assistance. Thank you.
      Patricia.
      Last edited by patricia70; 12-16-2020, 03:09 PM.

      Comment


        #4
        Hello patricia70,

        Thank you for that information.

        NT8 automatically adds an additional tick data series behind the scenes when using high fill resolution and tick data. In NT7 we had to manually perform this step. Can you clarify, please?

        That is correct. In NinjaTrader 8, High order fill resolution adds the 1-Tick series that would have needed to be added manually in NinjaTrader 7.

        Do I need to focus to Tick Replay or Using High Order Fill resolution?

        Since calculating OnBarClose will fill the entry orders on the next bar, you would need to use Tick Replay along with adding a 1-Tick series to your script and submitting the orders to the 1-Tick series. Enabling Tick Replay allows you to run your code OnEachTick or OnPriceChange instead of OnBarClose. When using Tick Replay, you will have to use AddDataSeries to add a 1-Tick series to replace the 1-Tick series that is added by High Order Fill since High Order Fill cannot be used with Tick Replay.

        Please let us know if we may further assist.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          That is correct. In NinjaTrader 8, High order fill resolution adds the 1-Tick series that would have needed to be added manually in NinjaTrader 7.
          How is that done by NT8? I just tested it by ensuring that I haven't added any additional data series to my strategy in builder. Then I choose "High Fill Resolution" with "1 minute" type and "Compile" it. Then I click the "View Code" button but there's absolutely no line "AddDataSeries..." in the shown code, I also have used the search function of the editor.

          Originally posted by NinjaTrader_BrandonH View Post
          Since calculating OnBarClose will fill the entry orders on the next bar, you would need to use Tick Replay along with adding a 1-Tick series to your script and submitting the orders to the 1-Tick series. Enabling Tick Replay allows you to run your code OnEachTick or OnPriceChange instead of OnBarClose. When using Tick Replay, you will have to use AddDataSeries to add a 1-Tick series to replace the 1-Tick series that is added by High Order Fill since High Order Fill cannot be used with Tick Replay.
          Initially my strategy code viewed from strategy builder looked like that:
          Code:
          protected override void OnBarUpdate()
          {
          if (BarsInProgress != 0)
          return;
          
          if (CurrentBars[0] < 1)
          return;
          
          // Set 1
          if ((Position.MarketPosition == MarketPosition.Flat) && (Close[0] > myIndicator.desiredPlotA[0])
          {
          EnterLong(Convert.ToInt32(DefaultQuantity), "");
          }
          
          // Set 2
          if (Position.MarketPosition == MarketPosition.Long)
          {
          ExitLongStopMarket(Convert.ToInt32(DefaultQuantity ), myIndicator.desiredPlotB[0], @"initial-SL", "");
          ExitLongLimit(Convert.ToInt32(DefaultQuantity), myIndicator.desiredPlotC[0], @"initial-TP", "");
          }
          }
          I've made a copy of that strategy and then unlocked the code and modified it to this (changes are highlighted in bold text):
          Code:
          else if (State == State.Configure)
          {
          AddDataSeries(Data.BarsPeriodType.Tick, 1);
          }
          protected override void OnBarUpdate()
          {
          if (BarsInProgress != 0 [B]|| CurrentBar < BarsRequiredToTrade || CurrentBars[0] < 1[/B])
          return;
          
          // Set 1
          if ((Position.MarketPosition == MarketPosition.Flat) && (Close[0] > myIndicator.desiredPlotA[0])
          {
          [B]EnterLong(1, Convert.ToInt32(DefaultQuantity), "Long: 1 tick");[/B]
          }
          
          // Set 2
          if (Position.MarketPosition == MarketPosition.Long)
          {
          ExitLongStopMarket([B]1, false,[/B] Convert.ToInt32(DefaultQuantity), myIndicator.desiredPlotB[0], @"initial-SL", "");
          ExitLongLimit([B]1, false,[/B] Convert.ToInt32(DefaultQuantity), myIndicator.desiredPlotC[0], @"initial-TP", "");
          }
          }
          Then I enabled tick replay and ensured that the strategy will by default use the standard fill resolution. In the chat data series I load 14 days. The tick replay is loaded and after a few seconds the chart is displayed. I enable the strategy and I need to wait up to 2 minutes that it finishes for calculating the strategy and display the results on the chart. My strategy does one single trade each day so I checked the 14 days in history. The opening position fills either occur at the exact price level of my plot line as expected or maximum 1 tick above. Most of the time the fills occured 1 tick above the plot value. I don't understand yet why this tick difference happen although there were no such high volatility in that certain time but I can live with it.

          My follow-up questions are:

          [1] Using Tick replay with a strategy developed for intra-bar fills
          When does such a high-cpu-consuming task like tick replay and intra-bar fill calculation as shown here making sense? I mean, by this behaviour I could really backtest for about 30 days maybe, everything else would stress my computer so much that I need to wait days for the calculation. I want to add that I'm using a high performance computer, 8 cores @4GHz, dozens Gigs of overclocked high-speed RAM and a perfect system setup which in general is optimized to high-speed.

          [2] Using High fill resolution with 1 minute series
          I don't necessarily need to use tick data for accurate fills in my strategy. I'd like to approach option 2. I could live with the fills happen at a 1min bar series. My primary viewing char time interval is 15min and I use high fill resolution with 1min type. I tried this approach explained many times here in the thread but it never worked as expected because the fills for opening a position occur at the following bar (after CurrentBar closes), although I was using high fill resolution. It does make no difference between "Standard Fill" or "High Resolution Fill". Why? Any clues how to debug this? I'd expect the fill happen exactly at the same price as when I would have used a 1min chart. But it doesn't.

          Looking forward to any help. Thank you so much.
          Patricia.
          Last edited by patricia70; 12-17-2020, 07:04 AM.

          Comment


            #6
            Hello patricia70,

            Thank you for your note.

            While Tick Replay lets us process logic OnEachTick/OnPriceChange, the orders are still filled by the data series they are submitted to.

            In order to achieve intrabar order fills and use Tick Replay, we cannot use High Order Fill Resolution and we will need to instead submit orders to a smaller data series.

            As we can see in the unlocked example, an additional data series is added and we use a different order method overload so we can submit that order to the added data series. The order method overload looks like so: EnterLong(int barsInProgressIndex, int quantity, string signalName)

            Code:
            else if(State == State.Configure)
            {
            /* Add a secondary bar series.
            AddDataSeries(Data.BarsPeriodType.Minute, 1);
            
            ...}
            Code:
            /*When the OnBarUpdate() is called from the primary bar series (5min series in the example), do the following */
            if (BarsInProgress == 0)
            {
                // When the fast EMA crosses above the slow EMA, enter long on the secondary (1min) bar series
                if (CrossAbove(EMA(Fast), EMA(Slow), 1))
                {
                    /* The entry condition is triggered on the primary bar series, but the order is sent and filled on the
            secondary bar series. The way the bar series is determined is by the first parameter: 0 = primary bars,
            1 = secondary bars, 2 = tertiary bars, etc. */
                    EnterLong(1, 1, "Long: 1min");
                }
            ...}
            This is not possible with the Strategy Builder and we would need to unlock the code to do this.

            1.Using Tick replay with a strategy developed for intra-bar fills
            This is a matter of preference if you want high accuracy fills, or if you want to get an idea for how the strategy would perform over that data set. If the strategy is designed to use OnPriceChange/OnEachTick, it may be best to backtest with Tick Replay + submitting orders to a single tick data series, or to use the Playback Connection so the intrabar movement that your strategy uses is simulated.

            2. Using High fill resolution with 1 minute series
            If you are submitting orders intrabar, you will want to have them filled with a relative data series. In other words, submitting orders to a single tick data series would be relevant since the orders would be submitted intrabar and should be filled with relative data. Submitting an order intrabar and getting it filled with less granular data (I.E. a 1 minute series) would not be relevant to when the order was submitted.

            Below is the example strategy for Backtesting NinjaScript Strategies with intrabar granularity and help guide documentation.
            SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm
            EnterLong - https://ninjatrader.com/es/support/h.../enterlong.htm
            AddDataSeries - https://ninjatrader.com/support/help...dataseries.htm

            Please let us know if we may further assist.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Hello again. I have tried a lot and still stuck. I'd like to make this very simple:

              --> Goal: no intra-bar granularity, I am ok with OHLC values in backtest history data. I want to have the fills happen at bar close at 1min interval, even when I look at the chart at 30min view.

              In strategy builder, I have set:

              Calculate: On bar close
              Order fill resolution: High
              Order fill resolution type: Minute
              Order fill resolution value: 1

              I am doing history backtest. But the fills happen at bar close at current chart view (=30min) although I would have expect them happen at 1min (higher granularity).

              Why? What am I doing wrong? any help appreciated. Thanks for your patience and trying to help me in understanding.

              Comment


                #8
                Hello patricia70,

                Thank you for your note.

                High order fill resolution will only set the Data Series used in the historical backfill algorithm. You would need to add a 1-minute series to your strategy using AddDataSeries() and submit orders to that Data Series by using a BarsInProgress == 1 check. BarsInProgress == 1 checks to see if the added 1-minute Data Series is being processed, and then you would submit your orders.

                See the help guide documentation below for more information about AddDataSeries and BarsInProgress.
                AddDataSeries - https://ninjatrader.com/support/help...dataseries.htm
                BarsInProgress - https://ninjatrader.com/support/help...inprogress.htm

                Please let us know if we may assist further.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Brandon. Thank you.

                  According to some explanations on the NT help guide and here on the forum I had the impression, that former version NT 7 needed to add the desired data series manually. But in version NT 8 this should happen automagically. Even when trying adding manually my desired 1min series I fail. That said, when I add a data series through:

                  Strategy Builder window --> Addional Data --> add:

                  Use primary instrument: check
                  Type: Minute
                  Value: 1

                  I get the error
                  'High' Order Fill Resolution is only available for single-series strategies. For multi-series strategies, please program directly into your strategy the more granular resolution you would like to simulate order fills with.
                  I am in strategy builder and I want to stay there without the need to unlock code. I want to have a single-series strategy and thus no need to unlock the code. How can I tell NT8 to really use the values that I configured under Strategy Builder --> Default Properties --> Order fill resolution, type and value? Obviously the high-order-fill-resolution part doesn't seem to work on my side. I want to add that my strategy is something very simple:

                  if condition occurs then EnterLong(DefaultQuantity, @"EnterLong");

                  Last edited by patricia70; 01-20-2021, 04:00 PM.

                  Comment


                    #10
                    Hello patricia70,

                    Thank you for your note.

                    Please test the SampleMACrossover strategy in the Strategy Analyzer using a 30-minute Data Series with both Standard order fill resolution and High order fill resolution set to 1-minute. Do you see Trades being filled at different times when comparing Standard order fill to High order fill set to 1-minute?

                    The error you are seeing is because if you add a secondary Data Series to your script, you wouldn't need to use High order fill resolution. You would need to use a Standard order fill resolution. This is cause you are adding the high order fill resolution in your script by adding the secondary series and submitting orders to it.

                    If you are using a 30-minute primary Data Series for backtesting your strategy and you would like to have orders fill intrabar on a 1-minute Data Series, you would need to unlock the code of your strategy, use AddDataSeries() to add a 1-minute series to your script, then use a BarsInProgress == 1 check, submit the orders to the 1-minute added series, and use Standard order fill resolution when backtesting. This is because the fill resolution setting is simply for order fills, not for the logic in your script.

                    Please let us know if we may assist further.


                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Brandon, thanks so far.
                      Originally posted by NinjaTrader_BrandonH View Post
                      If you are using a 30-minute primary Data Series for backtesting your strategy and you would like to have orders fill intrabar on a 1-minute Data Series, you would need to unlock the code of your strategy, use AddDataSeries() to add a 1-minute series to your script, then use a BarsInProgress == 1 check, submit the orders to the 1-minute added series, and use Standard order fill resolution when backtesting. This is because the fill resolution setting is simply for order fills, not for the logic in your script.
                      I know and understand the multi-series process and I already have done this successfully in another script. But in this case, I don't need to have orders filled intrabar. I am ok with order fills that happen right after the bar close. In the following, please let us focus on fill that are based on bar closes, no intra-bar granularity, no need for tick replay development. Let's keep this small and simple for showing and emphasizing the difference of "standard fill resolution" and "high fill resolution". I'm pretty sure this could be helpful for others, too.

                      Originally posted by NinjaTrader_BrandonH View Post
                      Please test the SampleMACrossover strategy in the Strategy Analyzer using a 30-minute Data Series with both Standard order fill resolution and High order fill resolution set to 1-minute. Do you see Trades being filled at different times when comparing Standard order fill to High order fill set to 1-minute?
                      this is not adequate and a helpful comparison because SampleMACrossOver is an unlocked strategy. For the sake of clarity, please let us stay at the strategy builder for now...

                      Originally posted by NinjaTrader_BrandonH View Post
                      The error you are seeing is because if you add a secondary Data Series to your script, you wouldn't need to use High order fill resolution.
                      that's what the error says, yes understood Unfortunately this still doesn't answer the previous mentioned part here...
                      Originally posted by patricia70
                      According to some explanations on the NT help guide and here on the forum I had the impression, that former version NT 7 needed to add the desired data series manually. But in version NT 8 this should happen automagically.
                      I did read through the help pages and explanations on this topic. For example a note from Paul was:
                      Originally posted by NinjaTrader_Paul
                      What High Order fill does is automatically add a data series of whatever you select for the fill processing. What happens is your code places an order but the order does not fill until the next bar. If you want the order to fill sooner you need a more granular series which is what high order fill can provide.

                      You would need to add a data series to your code of whatever you would have selected for the high order fill processing. In the OnBarUpdate, when that series calls onBarUpdate() you would need to return;
                      The sentences "What High Order fill does is automatically add a data series of whatever you select for the fill processing." and "You would need to add a data series to your code of whatever you would have selected for the high order fill processing" sound contrary to me.

                      It automatically adds the needed data series, despite we need to add it?

                      My understanding after all that was:
                      Via the "High Fill Resolution" function, I tell Ninjatrader8 to use a different time layer to process the fills, regardless of my chosen chart time interval. Furthermore, in the older NT7 you had to add the selected time layer for the high resolution manually and independently, while in NT8 this was probaly automated and thus Ninjatrader8 under the hood automatically adds the time layer chosen for high fill resolution.
                      However, my experience so far showed --> this does not work as I understand and expect. Also it is very confusing for me that it is said that you need to add an additionally data series to the code. On the other hand, when you add the secondary data series you receive the mentioned error. So what? :-)

                      I just double-checked by creating a simple new strategy with strategy builder:

                      Strategy Builder --> New Strategy
                      Name: TestingHighFillResolution
                      Description: No intra-bar granularity needed, no tick replay development needed, we calculate at bar close and nothing special here. We just switch to High Fill Resolution 1min
                      Calculate: On bar close
                      Conditions and Actions Set 1: If Default input[0] > Default input[1], do the following: EnterLong(DefaultQuantity, @"GoLong");
                      Conditions and Actions Set 2: If Default input[0] < Default input[1], do the following: EnterShort(DefaultQuantity, @"GoShort");
                      Finish.
                      I add this strategy to MES 03-21 30min and run it with standard fill resolution. I see the all positions entered are done at the open prices of a bar, just as expected. So far so good. I make a screenshot. Then I change the strategy options and choose "high fill order resolution" with 1 minute. I keep my chart time interval unchanged at 30min. I make a screenshot again. When comparing the two screenshots I see only one single difference in a fill when a position was closed on session end.

                      Simply said: Either I have a comprehension problem or I am doing something fundamentally wrong and am therefore confused.

                      Ninjatrader help for order fill resolution says:

                      [...]
                      Property Value


                      An enum value that determines how the strategy orders are filled. Default value is set to OrderFillResolution.Standard. Possible values are:
                      OrderFillResolution.Standard Faster - Uses the existing bar type and interval that you are running the backtest on to fill your orders.
                      OrderFillResolution.High More granular - Allows you to set a secondary bar series to be used as the price data to fill your orders. (See also OrderFillResolutionType and OrderFillResolutionValue)
                      [...]

                      Can anyone please explain slowly and as much detailled as possible what exactly the difference between OrderFillResolution.Standard and OrderFillResolution.High is? As you already said
                      Originally posted by NinjaTrader_BrandonH View Post
                      This is because the fill resolution setting is simply for order fills, not for the logic in your script.
                      this is a good point and proofs that I misunderstand the "high fill order resolution". Thanks for your patience and assistance.
                      Last edited by patricia70; 01-21-2021, 04:30 AM.

                      Comment


                        #12
                        Hello patricia70,

                        Thank you for your note.

                        When using Standard Order Fill Resolution, the behavior of order fills will be accurate to the close of the bar without any intra-bar information. This means that the historical fill algorithm will use the same Open, High, Low, Close, Time values that are available to the strategy for running the order fill simulation.

                        High Order Fill Resolution allows you to select a secondary data series to be used to provide intra-bar pricing information solely for the purpose of order fill accuracy. The highest you could set this to is 1 tick. High order fill resolution adds the secondary series that would have needed to be added manually in NinjaTrader 7. Order Fill Resolution is for order fill accuracy and not for the logic in your script.

                        Order fill resolution does not provide intra-bar granularity to OnBarUpdate for actions to be triggered intra-bar. If you are using a primary data series of 30-minutes but want orders to fill on a 1-minute series, this would be considered having orders fill intrabar.

                        If you want to stay in the Strategy Builder, you could consider adding the higher time frame as an additional data series and reference the 30-minute data series in the Conditions and Actions. If you apply the strategy to a 1-minute data series, you will have 1-minute logical processing and 1-minute order fill resolution. Since High Order Fill Resolution does not work with multi-series scripts, you would need to use a Standard Order Fill Resolution.

                        To clarify Paul's note, it was in reference to the original question in that forum post which was about using High Order Fill Resolution when the original poster already had multiple data series in his/her script.

                        Additionally, please see the forum post linked below for more information.


                        Please let us know if we may assist further.
                        Brandon H.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_BrandonH View Post
                          High Order Fill Resolution allows you to select a secondary data series to be used to provide intra-bar pricing information solely for the purpose of order fill accuracy.
                          Originally posted by NinjaTrader_BrandonH View Post
                          Order Fill Resolution is for order fill accuracy and not for the logic in your script.
                          Originally posted by NinjaTrader_BrandonH View Post
                          Order fill resolution does not provide intra-bar granularity to OnBarUpdate for actions to be triggered intra-bar. If you are using a primary data series of 30-minutes but want orders to fill on a 1-minute series, this would be considered having orders fill intrabar.
                          Dear Brandon,

                          I apologize for the long delay, but have only now found time to devote to this topic again. The keywords "fills" and "logic" have now made it understandable. Now I understand that these two things have to be considered and handled separately.

                          Thanks to your explanation, I was able to modify my code and adapt it to my needs as follows. As I'm interested in a particular data series only (in that example to the 1-min-interval bars), I do ignore the currently selected chart interval time whatever it is.
                          Code:
                          [...]
                          else if (State == State.Configure) {[INDENT]AddDataSeries(Data.BarsPeriodType.Minute, 1);[/INDENT]
                            }
                          [...]
                          protected override void OnBarUpdate()
                          {
                          // I don't care about primary data series set
                          if (BarsInProgress != 1)
                          return;
                          
                          if (Bars.IsFirstBarOfSession == true)
                          {
                          FirstTradeOpened = false;
                          }
                          
                          if (CurrentBars[0] < 1
                          || CurrentBars[1] < 1)
                          return;
                          
                          // example set for going long
                          if ((Position.MarketPosition == MarketPosition.Flat)
                          && (somecondition1 == true)
                          && (Times[1][0].TimeOfDay > TradeTimeFrom.TimeOfDay)
                          && (Times[1][0].TimeOfDay <= TradeTimeUntil.TimeOfDay)
                          && (Closes[1][0] > myIndicator.Value[0])
                          {
                          // debugging
                          // Print(string.Format("LONG trigger, CurrentBar = {0}, Time = {1}", CurrentBar, Time[1]);
                          EnterLong(Convert.ToInt32(DefaultQuantity), @"GoingLong");
                          FirstTradeOpened = true;
                          }
                          
                          // Set 3
                          if (Position.MarketPosition == MarketPosition.Long)
                          {
                          foo
                          bar
                          }
                          
                          }
                          this seems to work and I'm happy. Thanks a bunch for your patience and great assistance!!!
                          Patricia

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by ScottWalsh, 04-16-2024, 04:29 PM
                          6 responses
                          27 views
                          0 likes
                          Last Post ScottWalsh  
                          Started by frankthearm, Today, 09:08 AM
                          10 responses
                          35 views
                          0 likes
                          Last Post frankthearm  
                          Started by GwFutures1988, Today, 02:48 PM
                          0 responses
                          2 views
                          0 likes
                          Last Post GwFutures1988  
                          Started by mmenigma, Today, 02:22 PM
                          1 response
                          3 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by NRITV, Today, 01:15 PM
                          2 responses
                          9 views
                          0 likes
                          Last Post NRITV
                          by NRITV
                           
                          Working...
                          X