Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-timeframe and Indicator within strategy

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

    Multi-timeframe and Indicator within strategy

    Hi,

    I've searched the forum but have not found anything which explains how to do this.

    I have a simple strategy which uses stochastics over two time frames and currently displays the price data and the stochastics panel for the price data of the primary series.

    As a check that my strategy is working correctly I also want to display the stochastics of the higher time frame on another panel at the same time - effectively I want to do something like Add(Stochastics(...) for the secondary time frame) in Initialise.

    In summary I would like to display...

    Price Data (Primary timeframe - e.g. daily)
    Stochastics (Primary timeframe - e.g daily)
    Stochastics (Secondary timeframe - e.g. weekly)

    I can duplicate this on a standard chart by adding two data series and assigning Stochastics to two different periods of the same data series but would like to achieve the same thing within my ninja script code so that I can use it within the Strategy Analyzer.

    Thanks in advance for your help

    Oz

    #2
    Hi Oz, thanks for the post - I would suggest coding your indicators needed as MultiSeries ones and then ADD()ing those in the strategy for display, the SA should then show those, too in your backtesting chart.

    Thanks,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thanks for swift reply.

      I'm using the standard Stochastics indicator supplied with NT7 and it appears to have an overloaded method with an IDataSeries parameter.

      However, I'm struggling to see how I reference the other timeframe as an IDataSeries object. I'm used to using all of the BarsInProgress coding techniques within the OnBarUpdate section but I'd appreciate a point in the right direction with the missing bit below please!?

      For example I have this working...

      Add(PeriodType.Week, 1); // Adds my higher time frame

      Add(Stochastics(7,14,3)); // Plots a new panel based on the primary data
      Add(Stochastics(this.Close,7, 14, 3)); // Plots a new panel on the primary data too

      What I need to know is what do I replace the "this" in the second Add line with so that the indicator knows to reference the longer timeframe?

      Sorry if this is a basic question but I'm new to this part of NT scripting.

      Thanks again...

      Oz

      Comment


        #4
        Hi Oz,

        For this you have to add the additional series to an indicator, plot values using this additional series, and then you add the indicator as you have done there. I've attached a simple framework for this with an indicator that adds a series, and a strategy that plots them.
        Attached Files
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          Aha! I get it now - that's great.

          Thank you for the code snippet.

          Oz

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, 04-17-2024, 06:40 PM
          6 responses
          48 views
          0 likes
          Last Post algospoke  
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          61 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          9 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          20 views
          0 likes
          Last Post traderqz  
          Working...
          X