Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator calling a range of int periods

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

    Indicator calling a range of int periods

    Hi,

    I'm trying to create an indicator calling a range of int periods in realtime, not backtesting.
    Say testing on a crossover between SMA(period1) and SMA(period2), where period1 gets six different values between 15 and 20, and period2 gets values between 10 and 15.
    Could I use ArrayList or IntSeries?
    Please try to be specific - how to enter the seies data, and how to call it from the indicator.


    Thanks,
    bkool.
    Last edited by bkool; 10-05-2013, 10:00 AM.

    #2
    Hello bkool,

    You may use an Array to be able to accomplish something like this but if you are testing a strategy with a range of Period values for a Indicator it maybe easier to use the "Optimization" built into our Strategy Analyzer that will do this.

    Here is a link to our Help Guide that goes how to optimize a strategy that you may view that has an example of having two different SMA ranges set using our SampleMACrossOver strategy for reference to see if this will work for you.

    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks JC,

      I need this for realtime and not for backtesting.
      Please try to be specific.

      bkool.

      Comment


        #4
        Originally posted by bkool View Post
        Hi,

        I'm trying to create an indicator calling a range of int periods in realtime, not backtesting.
        Say testing on a crossover between SMA(period1) and SMA(period2), where period1 gets six different values between 15 and 20, and period2 gets values between 10 and 15.
        Could I use ArrayList or IntSeries.
        Please try to be specific - how to enter the seies data, and how to call it from the indicator.


        Thanks,
        bkool.
        Code:
        protected override void Initialize()
        {
        
        	Add("ES 12-13",    PeriodType.Minute, 3);  
        	Add("ES 12-13",    PeriodType.Minute, 5);  
        
        }
        
        protected override void OnBarUpdate()
        {
        if (Historical) return;
        
        if ( SMA(BarsArray[1][0],5)[15] > SMA(BarsArray[2][0],5)[10] )
        {
        ...

        Comment


          #5
          Thanks Sledge.
          Much appreciated.

          Is there another way for that using
          ArrayList or IntSeries?

          Comment


            #6
            Originally posted by bkool View Post
            Thanks Sledge.
            Much appreciated.

            Is there another way for that using
            ArrayList or IntSeries?

            Anybody there...?

            Comment


              #7
              Hello bkool,

              If you are testing out a range of periods the Optimization test in the Strategy Analyzer would work best for you so that way you do not have to create an an ArrayList or IntSeries.

              Does this not accomplish what you are looking for?
              JCNinjaTrader Customer Service

              Comment


                #8
                Thanks JC,

                As indicated, I need it not for finding a particular value out of a range, but for working with a range of periods in an indicator in realtime and backtesting.
                Is there a clean way to do it ?

                Comment


                  #9
                  Hello bkool,

                  An ArrayList would work for this yes or you can define your range of periods and loop through the periods that you would like since you can only pass 1 period variable at a time to an Indicator like the SMA.

                  For example:
                  Code:
                  int startvar = 15;
                  int endvar = 20;
                  			
                  for (int i = startvar; i<=endvar ; i++)
                  {
                  	Print("SMA of "+i+" is "+SMA(i)[0]);
                  }
                  JCNinjaTrader Customer Service

                  Comment


                    #10
                    Thanks again JC.

                    I was trying to avoid the loop.
                    Can you show me how this may work with an ArrayList?

                    Comment


                      #11
                      Hello bkool,

                      Using an ArrayList typically you would want to use a loop method to be able to have dynamic numbering otherwise it would be the same as hard coding all of the values.

                      Also, ArrayLists are not something that we can support, but Microsoft's website give a good example of this at the following link.
                      Implements the IList interface using an array whose size is dynamically increased as required.
                      JCNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      646 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      367 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      107 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      569 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X