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

MultiTimeframe strategy and SMA indicator

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

    MultiTimeframe strategy and SMA indicator

    Hello

    I have multiTimeframe strategy (DataSeries 1 and 2). Stategy will run on Dataseries #1 ( Timeframe H1) but I need check how 2 SMA will cross on Dataseries 2 (TimeFrame D1).
    How I can check it by using CroseAbove and Below functions?

    Thanks a lot

    #2
    Hello sergey_z,

    Thanks for your post.

    Please clarify if the 1-hour bars are the chart's bars or do you have a 3rd data series?

    What data series is the 2 period SMA built on, the hourly or the daily?

    What specifically are you looking to cross the 2 period SMA?

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello sergey_z,

      Thanks for your post.

      Please clarify if the 1-hour bars are the chart's bars or do you have a 3rd data series?

      What data series is the 2 period SMA built on, the hourly or the daily?

      What specifically are you looking to cross the 2 period SMA?
      1)Chart bars. TimeFrame 1Hour
      2)Daily.
      3) SMA1 = SMA(Close, 8);
      SMA2 = SMA(Open, 8);

      if (CrossBelow(SMA1, SMA2, 1) (do something)
      if (CrossAbove(SMA1, SMA2, 1) (do something)

      SMA1 and 2 have to calculate on D1 Timeframe (Dataseries #2). Strategy will run on Timeframe H1 (Dataseries #1)

      Thanks

      Comment


        #4
        Hello sergey_z,

        Thanks for your reply and clarifications.

        You would need to use the Close and Open "plurals" to access the other time frame. Please see "Accessing the Price Data in a Multi-Bars NinjaScript" here: https://ninjatrader.com/support/help...nstruments.htm

        You would create the local SMA referencing the Closes[] and Opens[] where the index is the BarsArray of the added data series. The chart bars (hourly bars) are BarsArray[0] and the daily would be BarsArray[1].

        SMA1= SMA(Closes[1], 8); // creates an 8 period SMA using daily bar close values
        SMA2=SMA(Opens[1], 8) // creates an 8 period SMA using daily bar open values
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          ok. thanks.
          And how I can plot SMA 1 and 2 from Strategy on Panel 2 (where I see H1 bars of Instrument) ?
          Code like SMA1.Panel = 1 or 2 dont plot SMA on this Subchart (Dataseries #2)

          Comment


            #6
            Hello sergey_z,

            Thanks for your reply.

            Perhaps I am not understanding but I thought the hourly bars are the chart bars which would have to be in the price panel, panel #1.

            Could you provide a screenshot of your chart to clarify?

            Thank-you.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Now its works. I have to delete and apply strategy again after changing number of Panel in a code.
              This is what I need. now its ok

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,222 views
              0 likes
              Last Post xiinteractive  
              Started by andrewtrades, Today, 04:57 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              7 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              438 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              10 views
              0 likes
              Last Post FAQtrader  
              Working...
              X