Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-Time frame strategy - BarsSinceExit

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

    Multi-Time frame strategy - BarsSinceExit

    All,

    In a Multi-Time frame strategy, it would appear the syntax BarsSinceExit(int barsInProgressIndex, string signalName, int exitsAgo) returns the count of bars in terms of the primary bar object.

    While the "barsInProgressIndex" can be appropriately directed to the index of the Bars object the entry order was submitted against, the returned bar count remains in terms of the primary Bars object.

    How can the BarsSinceExit be measured against the secondary or tertiary Bars objects?

    Regards
    Shannon

    #2
    Shannon, what happens if you place the BarsSinceExit() inside a BarsInProgress identifier like so?
    Code:
    OnBarUpdate()
    {
        if (BarsInProgress == 1)
        {
            BarsSinceExit(BIP = 1);
        }
    }
    If you feel this could be a bug, could you please create a simple script that demonstrates this behavior? Thank you.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Austin,

      Thanks for the quick reply.

      The code is arranged to make use of IOrders. The Entry is triggered from the "OnBarUpdate()" block following a BarsSinceExit() condition, while the IOrder stopOrder is set via the ExitLongStop() or ExitLongLimit() methods from the "OnExecution()" block (defining the BarsInProgress the same as the entry timeframe).

      Should the "OnExecution()" block contain an
      Code:
       
      if (BarsInProgress ==1)
      { 
        etc
      Thanks and regards
      Shannon
      Last edited by Shansen; 01-18-2010, 02:49 AM.

      Comment


        #4
        Shannon, don't believe this would be needed as BarsSinceEntry / Exit have their own BIP parameter - against which bars objects do you execute in your strategy?

        Comment


          #5
          Bertrand,

          The strategy while run on a 15min chart (primary Bars objet), the strategy is executed on a 1min dataSeries (Bars object with an index of 3).

          As shown in the attached code snippet, I believe the strategy is executing on the Bars Object index of 3.

          Code:
          protected override void OnBarUpdate()
          {
            .
            .
            .
            if (BarsInProgress != 3 || CurrentBar < 100)
              return;	  
            .
            .
            .  // [I]enterhere[/I] boolean variable set as true or false
          
          
            if ([I]enterhere[/I] && (BarsSinceExit(3,"Long",0) == -1 || BarsSinceExit(3,"Long",0) >= 6)) // Six bars since last entry
            {
              Print ("BarsSinceExit " + BarsSinceExit(3,"Long",0)); // for debugging purposes
              if (entryOrder == null)
              {
                entryOrder = EnterLong(3, DefaultQuantity, "Long");
              }
            }
          }
          
          protected override void OnExecution(IExecution execution)
          {
            if (entryOrder != null && entryOrder.Token == execution.Order.Token)
            {
              if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
              {
                if (Position.MarketPosition == MarketPosition.Long)
                {
                  stopOrder = ExitLongStop(3, true, execution.Order.Filled, LongEntryLow, "LongStop", "Long");
                  targetOrder = ExitLongLimit(3, true, execution.Order.Filled, execution.Order.AvgFillPrice + 2 * TickSize, "LongTarget", "Long");
                }
              }
            }
          }
          As always any assistance would be greatly appreciated.
          Regards
          Shannon

          Comment


            #6
            Shansen, this is correct it executes to the BIP 3 (might need to doublecheck into your bars series order as they start from 0, so the third one would have an index of 2).

            Do you the same results for backtesting and historical trades from BarsSinceExit to BIP3?

            Thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            627 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            359 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            562 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X