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

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:



    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 CortexZenUSA, Today, 12:53 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Started by CortexZenUSA, Today, 12:46 AM
                0 responses
                0 views
                0 likes
                Last Post CortexZenUSA  
                Started by usazencortex, Today, 12:43 AM
                0 responses
                2 views
                0 likes
                Last Post usazencortex  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                168 responses
                2,262 views
                0 likes
                Last Post sidlercom80  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X