Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

series of indicator of indicator changing update policy

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

    series of indicator of indicator changing update policy

    Hey NT crew,

    I've got a multi-granularity strategy that uses a indicator of another indicator in the second granularity.

    It appears that adding the indicator as an IDataSeries is causing the update policy to change for all the indicators in the strategy.

    Is there anyway you know of to avoid this and keep the indicator as an IDataSeries?

    Code:
     
    namespace NinjaTrader.Strategy
    {
    public class UpdateIssue : Strategy
    {
    private IDataSeries indicator;
     
    protected override void Initialize()
    {
    Add(BarsPeriod.Id,5);
    CalculateOnBarClose = true;
    }
     
    protected override void OnStartUp() 
    { 
    ClearOutputWindow();
    // indicator = SMA(Closes[1],8);
    indicator = SMA(BarChange(Closes[1]),8);
    }
    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0) return;
     
    DateTime barTime = Times[BarsInProgress][0];
    string time = string.Format("{0:g}\t{1:0.00}",barTime,Closes[1][0]);
    string test1 = string.Format("\t{0:0.00}",BarChange(Closes[1])[0]);
    string test2 = string.Format("\t{0:0.00}",SMA(BarChange(Closes[1]),8)[0]);
    string test3 = string.Format("\t{0:0.00}",indicator[0]);
    Print(time + test1 + test2 + test3);
    }
    }
    }
    gives this output:
    Code:
     
    2/10/2011 3:52 PM 132.41 0.16 0.07 0.07
    2/10/2011 3:53 PM 132.41 0.16 0.08 0.08
    2/10/2011 3:54 PM 132.41 0.16 0.10 0.10
    2/10/2011 3:55 PM 131.99 -0.43 0.05 0.05
    2/10/2011 3:56 PM 131.99 -0.43 -0.01 -0.01
    2/10/2011 3:57 PM 131.99 -0.43 -0.06 -0.06
    2/10/2011 3:58 PM 131.99 -0.43 -0.13 -0.13
    2/10/2011 3:59 PM 131.99 -0.43 -0.21 -0.21
    when you change the OnStartUp to

    Code:
     
    indicator = SMA(Closes[1],8);
    // indicator = SMA(BarChange(Closes[1]),8);
    the results are as expected:

    Code:
     
    2/10/2011 3:52 PM 132.41 0.16 0.05 132.19
    2/10/2011 3:53 PM 132.41 0.16 0.05 132.19
    2/10/2011 3:54 PM 132.41 0.16 0.05 132.19
    2/10/2011 3:55 PM 131.99 -0.43 -0.01 132.18
    2/10/2011 3:56 PM 131.99 -0.43 -0.01 132.18
    2/10/2011 3:57 PM 131.99 -0.43 -0.01 132.18
    2/10/2011 3:58 PM 131.99 -0.43 -0.01 132.18
    2/10/2011 3:59 PM 131.99 -0.43 -0.01 132.18

    #2
    Hello darckeen,

    For custom data series, you can follow according to this post:


    To create an indicator instance:
    private SMA mySMA; //variables region
    mySMA = SMA(BarChange(Closes[1]),8); //OnStartup()

    I'm not sure what private IDataSeries indicator; is doing but it's not typically used like this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I'm finding that using SMA rather then IDataSeries as the class causes the same unexpected behavior.

      Comment


        #4
        Hi darckeen,

        Can you please provide a code snippet that's not working the way you expect. Also, include a description of what you expect it to do and what you're seeing happen instead.

        From your original post, can you clarify "update policy"?
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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