Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Sample Intrabar Backtest

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

    #16
    Hi aventeren,

    I think what you are getting at is the following issue.

    Adding intra-bar granularity does not cause the primary data series to have the current price from the added tick series.

    This means that as you make calculations, yes, you can have this run on every tick, but it will still have the close price of the last bar instead of the current tick's price.

    With Calculate on bar close set to false, this will actually return the primary bar closes but will use the current tick's price.

    Am I understanding the issue correctly?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      Originally posted by NinjaTrader_ChelseaB View Post
      Hi aventeren,

      I think what you are getting at is the following issue.

      Adding intra-bar granularity does not cause the primary data series to have the current price from the added tick series.

      This means that as you make calculations, yes, you can have this run on every tick, but it will still have the close price of the last bar instead of the current tick's price.

      With Calculate on bar close set to false, this will actually return the primary bar closes but will use the current tick's price.

      Am I understanding the issue correctly?
      Yes and no. The logic is not looking at the Close values--but rather the real time COBC == false High[0] and Low[0] as they develop. Therefore, when Low[0] prints a price that is 1 tick below Low[1] (and High[2] <= High[1] && High[1] > High[0] && Low[2] <= Low[1]), at the moment that Low[0] = Low[1] - TickSize, the swing high would have been created and confirmed. It is at that moment that I am trying to get the backtest to simulate a filled limit order with a limit price of Low[1] - TickSize using the NT7 fill engine.

      Do you have any ideas on how I can accomplish this intrabar historical fill scenario?

      Comment


        #18
        Chelsea--

        I have attached a really simple strategy that does what I am saying.

        Is there a way to have this strategy fire limit orders within the bars that meet the if conditions?

        Thanks,

        Aventeren
        Attached Files

        Comment


          #19
          Hi aventeren,

          The script attached has a 1 minute added data series. You are trying to find when the price hits the low from one bar ago correct?

          Try adding a 1 tick series.

          Then use:

          Lows[0][0] for the primary low, and Closes[1][0] for the current tick value.

          Also, be sure you are processing on BarsInProgress 1.

          Yes, with that done, you should be able to detect this on the exact tick.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            Originally posted by NinjaTrader_ChelseaB View Post
            Hi aventeren,

            The script attached has a 1 minute added data series. You are trying to find when the price hits the low from one bar ago correct?

            Try adding a 1 tick series.

            Then use:

            Lows[0][0] for the primary low, and Closes[1][0] for the current tick value.

            Also, be sure you are processing on BarsInProgress 1.

            Yes, with that done, you should be able to detect this on the exact tick.
            Thanks, Chelsea. I've made the suggested changes, although I used a 1 Range secondary series instead of the suggested 1 Tick secondary series. However, when I run this strategy on a weekly chart, I am still not seeing intrabar fills.

            Using a 1 Tick series crashes NT. I'm running Windows 7 64 bit with 16 GB of RAM on an Intel i7 dual core processor with a 1 TB SSD.

            Any ideas?

            Thanks,

            Aventeren
            Attached Files
            Last edited by aventeren; 09-29-2014, 02:54 PM.

            Comment


              #21
              The issue is here. That is what I meant by you have to be more precise in your statement of the specification.
              3. Within BIP == 0, checking to see if High[2] < High [1] && High[1] > High[0] && Low[0] < Low[1] for a swing high and vice versa for a swing low.
              You are again looking at 3 bars, whereas given the newer description that you have given , you are looking for the break of the low of the second bar regardless what might happen after that break. That means that you have to start examining the intrabar series once the second bar closes, not looking at the primary series for another bar, in the first instance.
              Code:
              private bool enterOnLowBreak = false;
              private int potentialSwingHighBar = -1;
              private double shortEntryValue = 0.0;
              Code:
              if (BarsInProgress == 0)
              {
              if (High[2] < High[1]) //potential swing high bar, because we are not waiting to see what happens on the next bar, and we have the first 2 bars that can become a swing high.
              {
              enterOnLowBreak = true;
              potentialSwingHighBar = CurrentBar;
              shortEntryValue = Low[0] - TickSize;
              }
              }
              if (BarsInProgress == 1)
              {
              if (enterOnLowBreak && potentialSwingHighBar == CurrentBars[0]) //are we still on the same triggering potential SwingHigh bar?
              {
              //We enter here, by checking if Low[0] is less than the shortEntryValue 
              if (Low[0] < shortEntryValue) 
              {
              EnterShort ...();
              //turn off the filters
              enterOnLowBreak = false; 
              potentialSwingHighBar = -1; 
              shortEntryValue = 0.0;
              }
               }
              else
              {
              //We did not get an entry, so reset all the triggers, if we have closed the potentialSwingHighBar
              if (potentialSwingHighBar != CurrentBars[0] && potentialSwingHighBar != -1)
              {
              enterOnLowBreak = false;
              potentialSwingHighBar = -1;
              shortEntryValue = 0.0;
              }
              }
              }
              Untested pseudocode, just showing the reasoning behind the method.
              Last edited by koganam; 09-29-2014, 09:32 PM. Reason: Corrected spelling.

              Comment


                #22
                Originally posted by koganam View Post
                The issue is here. That is what I meant by you have to be more precise in your statement of the specification.
                You are again looking at 3 bars, whereas given the newer description that you have given , you are looking for the break of the low of the second bar regardless what might happen after that break. That means that you have to start examining the intrabar series once the second bar closes, not looking at the primary series for another bar, in the first instance.
                Code:
                private bool enterOnLowBreak = false;
                private int potentialSwingHighBar = -1;
                private double shortEntryValue = 0.0;
                Code:
                if (BarsInProgress == 0)
                {
                if (High[2] , High[1]) //potential swing high bar, because we are not waiting to see what happens on the next bar, and we have the first 2 bars that can become a swing high.
                {
                enterOnLowBreak = true;
                potentialSwingHighBar = CurrentBar;
                shortEntryValue = Low[0] - TickSize;
                }
                }
                if (BarsInProgress == 1)
                {
                if (enterOnLowBreak && potentialSwingHighBar == CurrentBars[0]) //are we still on the same triggering potential SwingHigh bar?
                {
                //We enter here, by checking if Low[0] is less than the shortEntryValue 
                if (Low[0] < shortEntryValue) 
                {
                EnterShort ...();
                //turn off the filters
                enterOnLowBreak = false; 
                potentialSwingHighBar = -1; 
                shortEntryValue = 0.0;
                }
                 }
                else
                {
                //We did not get an entry, so reset all the triggers, if we have closed the potentialSwingHighBar
                if (potentialSwingHighBar != CurrentBars[0] && potentialSwingHighBar != -1)
                {
                enterOnLowBreak = false;
                potentialSwingHighBar = -1;
                shortEntryValue = 0.0;
                }
                }
                }
                Untested pseudocode, just showing the reasoning behind the method.
                koganam--

                This is super helpful. Thanks. I really appreciate your feedback. I'll code this up and see how things shake out.

                Thanks,

                Aventeren

                Comment


                  #23
                  Best order type

                  I have a question about which order type will perform as I need it to on a backtest and live trading:

                  I am going to basically have an entry order sitting 1 tick above (long) or below (short) a potential swing set up sequence (i.e., when the first two bars are set up for the swing reversal, I'll place the order at the Close of the 2nd bar), what order type is best? My choices (as I see it) are:

                  EnterShortLimit(1, true, 1, Low[0] - TickSize, "short")
                  and
                  EnterShortStopLimit(1, true, 1, Low[0] - TickSize, High[0] + TickSize, "short")

                  Which of these two order types will allow me to place a prospective short limit entry order that will only execute if the Low of the 3rd bar trades through the limit price? For instance, I don't want the short order to fill on the 3rd bar if price is above the short limit price, which in theory might (?) happen because NT thinks that a better short price can be obtained by going short at a higher price.

                  101 strategy stuff.

                  Thanks,

                  Aventeren

                  Comment


                    #24
                    Originally posted by aventeren View Post
                    I have a question about which order type will perform as I need it to on a backtest and live trading:

                    I am going to basically have an entry order sitting 1 tick above (long) or below (short) a potential swing set up sequence (i.e., when the first two bars are set up for the swing reversal, I'll place the order at the Close of the 2nd bar), what order type is best? My choices (as I see it) are:

                    EnterShortLimit(1, true, 1, Low[0] - TickSize, "short")
                    and
                    EnterShortStopLimit(1, true, 1, Low[0] - TickSize, High[0] + TickSize, "short")

                    Which of these two order types will allow me to place a prospective short limit entry order that will only execute if the Low of the 3rd bar trades through the limit price? For instance, I don't want the short order to fill on the 3rd bar if price is above the short limit price, which in theory might (?) happen because NT thinks that a better short price can be obtained by going short at a higher price.

                    101 strategy stuff.

                    Thanks,

                    Aventeren
                    An At-Price-And-No-Better order is a StopLimit order. You. however, have to account for gaps, by testing and using a Limit Order if there is a gap, or you will get the error about placing same-direction Stop orders behind the market.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by arvidvanstaey, Today, 02:19 PM
                    4 responses
                    11 views
                    0 likes
                    Last Post arvidvanstaey  
                    Started by samish18, 04-17-2024, 08:57 AM
                    16 responses
                    61 views
                    0 likes
                    Last Post samish18  
                    Started by jordanq2, Today, 03:10 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post jordanq2  
                    Started by traderqz, Today, 12:06 AM
                    10 responses
                    18 views
                    0 likes
                    Last Post traderqz  
                    Started by algospoke, 04-17-2024, 06:40 PM
                    5 responses
                    48 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X