Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MultiTimeFrame Query - Use of BarsInProgress

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

    MultiTimeFrame Query - Use of BarsInProgress

    I am running a MTF strategy that looks for a setup on the primary time frame BarsArray[0] and then executes on the secondary time frame BarsArray[1] and i was wondering what the difference would be between these 3 scripts:

    Code:
    if (BarsInProgress == 0)
    {
    	if (CrossAbove(EMA(Fast), EMA(Slow), 1))
    		{
    			//1 = secondary bars,
    			EnterLong(1, 1, "Long");
    		}
    and
    Code:
    if (BarsInProgress == 1)
    {
    	if (CrossAbove(EMA(BarsArray[0],Fast), EMA(BarsArray[0],Slow), 1))
    		{
    			//1 = secondary bars,
    			EnterLong(1, 1, "Long");
    		}
    and
    Code:
    if (BarsInProgress == 0)
    {
    	if (CrossAbove(EMA(BarsArray[0],Fast), EMA(BarsArray[0],Slow), 1))
    		{
    			//1 = secondary bars,
    			EnterLong(1, 1, "Long");
    		}

    #2
    Your first example, will be called when the primary series updates, but since you're not reference any specific bars array, will only check the EMA for the BarsInProgress series you have put that code under.

    The second will operate when BarsInProgess 1 updates, but will use the data from the BarsArray[0], or primary series.

    The 3rd will be called when the primary series is updated, and will use data from the Primary Series.

    In all of your examples, the EnterLong will operate on the secondary series as you have specified 1 as the barsInProgressIndex.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Matthew View Post
      Your first example, will be called when the primary series updates, but since you're not reference any specific bars array, will only check the EMA for the BarsInProgress series you have put that code under.

      The second will operate when BarsInProgess 1 updates, but will use the data from the BarsArray[0], or primary series.

      The 3rd will be called when the primary series is updated, and will use data from the Primary Series.

      In all of your examples, the EnterLong will operate on the secondary series as you have specified 1 as the barsInProgressIndex.
      Ok, therefore given my initial remarks and the simple code, do you agree with me that all 3 examples should return the same result?

      Comment


        #4
        As far as your data is referenced yes, however in the second example would only be called when the secondary series is updated.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Originally posted by NinjaTrader_Matthew View Post
          As far as your data is referenced yes, however in the second example would only be called when the secondary series is updated.
          This is all very clear, i only have 1 doubt:

          -Assuming I am running the code below and I want to enter long with a limit. My BIP=0 is 60 min time frame whilst execution will occur on the 1 min time frame. I will send the order on the BIP=1, but will this order be valid for only 1 minute or 60 min?

          Code:
          if (BarsInProgress == 0)
          {
          	if (longcondition == true)
          		{
          			EnterLongLimit(1, false,DefaultQuanitity,High[0], "Long");
                                  //1 = secondary bars;
          		}

          Comment


            #6
            If you're running on CalculateOnBarClose = true, it would only evaluated every 60-minutes.

            If it was CalculateOnBarClose = false, it would submit as soon as the instrument received an update.

            You may want to consider using unique print statements to get a better idea of what order and time your code will be called.
            MatthewNinjaTrader Product Management

            Comment


              #7
              Matt, thanks for reply, but it doesn't really answer my question. I was referring to the fact that the the field valid till cancel = false, therefore I was wondering if the order is valid for a 1 min bar or a 60 min bar

              Comment


                #8
                As your logic occurs on BIP0, it will be live until BIP0 bar closes; in your case it will cancel 60-minutes after it has been placed.
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Originally posted by NinjaTrader_Matthew View Post
                  As your logic occurs on BIP0, it will be live until BIP0 bar closes; in your case it will cancel 60-minutes after it has been placed.
                  ok this helps thanks

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  656 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  371 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  574 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  579 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X