Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Time Frame Trigger

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

    Multi Time Frame Trigger

    I want to trigger an order if two different TimeFrames agree ie: 5 min shows a buy and 1 min shows a buy then buy..
    Can I do this with the BarsInProgress?

    #2
    1st : Code your strategy to be placed on the lowest time frame ( 1Min )
    2nd : On Initialize() add " Add(PeriodType.Minute,5);
    3rd : On OnBarUpdate() is going to run each time a bar closes on both timeframes
    You can check that by if (BarsInProgress == 0) then 1Min bar is triggering
    Then u can check a condition ( like SMA(50)[0] ) on both timeframes by
    SMA(BarsArray[1], 20)[0] // for the 5 Min
    SMA(Close, 20)[0] // fro the 1 min
    pmaglio
    NinjaTrader Ecosystem Vendor - The Indicator Store

    Comment


      #3
      Hello gg80108,

      Thank you for your post.

      You need to use a combination of BarsInProgress, BarsArray, and Closes, Opens, Highs, Lows for this. The snippet below buys when Close is greater than the 14 period SMA for the two different series. The BarsInProgress == 0 check will ensure that this is only performed during updates to the primary series but the BarsArray and Closes properties tell it to look at values in the secondary series.

      Code:
       
      if (BarsInProgress == 0)
      {
      if(Close[0] > SMA(Close, 14)[0] && Closes[1][0] > SMA (BarsArray[1], 14)[0])
      EnterLong();
      }
      The following link will take you to the strategy multi-time-frame article of our help guide:
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        Excellent. Thanks for sharing, pmaglio!
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Interesting thread. I'm still stuck though.
          I'm trying to do a two step entry. Run a handful of proprietary indicators on a longer time frame, eg 50 ticks. If those conditions are met (a bunch of them), then run some proprietary indicators on shorter time frame, eg 5 tck bars, but only for about 2 periods of the longer timer frame.
          Any assistance would be helpful (v 6.5)
          Steve

          Comment


            #6
            Hi Steve,

            Thank you for your post.

            You can see a sample multi time frame strategy by clicking Tools > Edit NinjaScript > Strategy > Sample Multitime frame.

            If you only want to evaluate your secondary series after the primary series is true, you can set and check bool values to code the sequence you're looking for.

            if (firstSeriesConditions)
            evaluateSecondSeriesNow = true;

            if (evaluateSecondSeriesNow && secondSeriesConditions)
            //place orders here

            Someplace later you would reset the bool values - possibly when flat.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            646 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            367 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X