• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order fill resolution on high but not working?

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

    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. Thanks

    #2
    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:

    https://ninjatrader.com/support/help...ipt_strate.htm

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      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


        #4
        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");
                  }
            }
        That code would try to enter on each bar of the secondary series - obviously you'd have to add your own conditions so it only enters on your trigger.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          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), "", "");
          }
          
          }
          }
          }
          I tried editing this with using your suggestions a variety of ways. I could get it to enable and run but when I tried turning on order fill resolution to high it gives me error order fill resolution is only available for single-series strategies ect... and disables. Where exactly do I put the below line?

          if (BarsInProgress == 1)

          Thank you
          Last edited by jerblaster23; 01-08-2020, 05:38 PM.

          Comment


            #6
            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), "", "");
            }
            }
            }
            }
            }
            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              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


                #8
                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;
                Remove that and you should see your trades being taken on the secondary series.

                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 Captain_Qwark, Today, 10:55 AM
                3 responses
                19 views
                0 likes
                Last Post NinjaTrader_PaulH  
                Started by kmpc1, Today, 11:03 AM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_PatrickG  
                Started by jransom, Today, 09:08 AM
                1 response
                19 views
                0 likes
                Last Post NinjaTrader_Kate  
                Started by mtamaku, Today, 09:19 AM
                0 responses
                23 views
                0 likes
                Last Post mtamaku
                by mtamaku
                 
                Started by traderMNQ, Today, 09:00 AM
                4 responses
                20 views
                0 likes
                Last Post traderMNQ  
                Working...
                X