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

Reference multiple timeframes

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

    Reference multiple timeframes

    I would like to create a strategy that will, for instance, use an indicator on the current chart, say a 1hr chart, but then include, in the same strategy, a reference to an indicator on a 30 min chart. If both conditions are true I will do something.
    Can this be done. If so, can you give me a code snippet that accomplishes this?
    Regards,
    Duke

    #2
    Hello Duke,

    Thank you for your note.

    Yes this can be done through NinjaScript to make this a Multi-Instrument strategy.

    Please see the following Help Guide link for general information on Multi-Instrument/Time Frame scripts.



    To add a 30 minute Time Frame you will have the following code:

    protected override void Initialize()
    {
    // Add a 30 minute Bars object - BarsInProgress index = 1
    Add(PeriodType.Minute, 30);
    }

    You can then use this as part of a check in your strategy to check for true conditions.

    CameronNinjaTrader Customer Service

    Comment


      #3
      Thanks Cameron.. the ref really helped.. another thing

      Originally posted by NinjaTrader_Cameron View Post
      Hello Duke,

      Thank you for your note.

      Yes this can be done through NinjaScript to make this a Multi-Instrument strategy.

      Please see the following Help Guide link for general information on Multi-Instrument/Time Frame scripts.



      To add a 30 minute Time Frame you will have the following code:

      protected override void Initialize()
      {
      // Add a 30 minute Bars object - BarsInProgress index = 1
      Add(PeriodType.Minute, 30);
      }

      You can then use this as part of a check in your strategy to check for true conditions.

      http://www.ninjatrader.com/support/h....html?add3.htm
      If I have the following:
      Add(period.minute,3); --- 3 min chart
      How can I use a variable for the '3' so that I can change on input screen?
      Thanks,
      Duke

      Comment


        #4
        Hello Duke,

        You can use an int Variable to change the secondary data series on the Indicator input panel.

        Example:


        private int test = 3;


        protected override void Initialize()
        {
        Add(PeriodType.Minute, Test);
        }
        CameronNinjaTrader Customer Service

        Comment


          #5
          Thank you Cameron... I will give this a try.
          Duke

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by usazencort, Today, 01:16 AM
          0 responses
          1 view
          0 likes
          Last Post usazencort  
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          603 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          6 responses
          22 views
          0 likes
          Last Post xiinteractive  
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          21 views
          0 likes
          Last Post Pattontje  
          Started by flybuzz, 04-21-2024, 04:07 PM
          17 responses
          230 views
          0 likes
          Last Post TradingLoss  
          Working...
          X