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 Segwin, 05-07-2018, 02:15 PM
              14 responses
              1,789 views
              0 likes
              Last Post aligator  
              Started by Jimmyk, 01-26-2018, 05:19 AM
              6 responses
              837 views
              0 likes
              Last Post emuns
              by emuns
               
              Started by jxs_xrj, 01-12-2020, 09:49 AM
              6 responses
              3,294 views
              1 like
              Last Post jgualdronc  
              Started by Touch-Ups, Today, 10:36 AM
              0 responses
              13 views
              0 likes
              Last Post Touch-Ups  
              Started by geddyisodin, 04-25-2024, 05:20 AM
              11 responses
              63 views
              0 likes
              Last Post halgo_boulder  
              Working...
              X