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 bortz, 11-06-2023, 08:04 AM
          47 responses
          1,606 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          8 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          4 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          13 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X