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

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 elderan, Today, 08:03 PM
        0 responses
        1 view
        0 likes
        Last Post elderan
        by elderan
         
        Started by algospoke, Today, 06:40 PM
        0 responses
        10 views
        0 likes
        Last Post algospoke  
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        8 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        7 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        169 views
        0 likes
        Last Post jeronymite  
        Working...
        X