Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

using idicators within indicators

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

    using idicators within indicators

    i have a custom indicator, "AveRange" which calculates the SMA of daily range. I have another, "SDRange" that calculates the Stddev of range.

    I would like to create an indicator, "RangeRatio" which calculates "AveRange" / "SDRange"

    I tried to create 3 DataSeries (one for Range, one for Averange, and one for SDRange) because i wasnt sure how to call an indicator within an indicator.

    i then tried to ...

    Code:
    protected override void OnBarUpdate()
            {
    		
    			
    			myRange.Set(Close[0] - Open[0]);
    			myAveRange.Set(SMA(myRange,Period));
    			mySDRange.Set(StdDev(myRange,Period));
    			
    			
                AvgRatio.Set(myAveRange/mySDRange)[0];
            }
    but couldnt use the divide operator on a DataSeries

    i would like to know the easier way to do this but i would also like to know why this way wouldnt work. Thanks. BB

    #2
    Hello BB,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    You can actually use divide, but you need to use the barsAgo index for the Data Series here:
    Code:
    AvgRatio.Set(myAveRange[0]/mySDRange[0]);

    Comment


      #3
      Originally posted by wlblount View Post
      i have a custom indicator, "AveRange" which calculates the SMA of daily range. I have another, "SDRange" that calculates the Stddev of range.

      I would like to create an indicator, "RangeRatio" which calculates "AveRange" / "SDRange"

      I tried to create 3 DataSeries (one for Range, one for Averange, and one for SDRange) because i wasnt sure how to call an indicator within an indicator.

      i then tried to ...

      Code:
      protected override void OnBarUpdate()
              {
              
                  
                  myRange.Set(Close[0] - Open[0]);
                  myAveRange.Set(SMA(myRange,Period));
                  mySDRange.Set(StdDev(myRange,Period));
                  
                  
                  AvgRatio.Set(myAveRange/mySDRange)[0];
              }
      but couldnt use the divide operator on a DataSeries

      i would like to know the easier way to do this but i would also like to know why this way wouldnt work. Thanks. BB
      You are missing the indices on your DataSeries invocations, and a spurious index on your last Set statement.
      Code:
      myRange.Set(Close[0] - Open[0]);
                  myAveRange.Set(SMA(myRange,Period)[SIZE=3][COLOR=Blue][B][0][/B][/COLOR][/SIZE]);
                  mySDRange.Set(StdDev(myRange,Period)[SIZE=3][COLOR=Blue][B][0][/B][/COLOR][/SIZE]);
                  
                  
                  AvgRatio.Set(myAveRange[SIZE=3][COLOR=Blue][B][0][/B][/COLOR][/SIZE]/mySDRange[SIZE=3][COLOR=Blue][B][0][/B][/COLOR][/SIZE])[B][COLOR=Red][0][/COLOR][/B];
      The index marked in bold red should not be there. In other words, your last line should read:
      Code:
                  AvgRatio.Set(myAveRange[SIZE=3][COLOR=Blue][B][0][/B][/COLOR][/SIZE]/mySDRange[SIZE=3][COLOR=Blue][B][0][/B][/COLOR][/SIZE])[B][COLOR=Red][/COLOR][/B];

      Comment


        #4
        Thank you Gentleman - that worked perfectly. The "SampleCustomDataSeries" is a great template. I had a bunch of simple, "Market Analyzer" type indicators on TOS and at day 3 with NT, I have been able to reproduce almost all of them. BB

        Comment

        Latest Posts

        Collapse

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