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 sjsj2732, 03-23-2026, 04:31 AM
        0 responses
        76 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        313 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        311 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        149 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        111 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X