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

Secondary Series and Data, Int, Bool Series

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

    Secondary Series and Data, Int, Bool Series

    I add a Secondary Series, 60 Minute to a Primary Daily, and then want to add DataSeries / IntSeries / BoolSeries to the Secondary Series.

    How do I get the DataSEries / IntSeries / BoolSeries to attach to the Secondary Series? The following code wants to attach to the Primary Series.

    The following code throws Exception:
    BIP == 1: Bar: 13
    Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    at System.Collections.ArrayList.get_Item(Int32 index)
    at NinjaTrader.Data.DataSeries.Set(Double value)
    at NinjaTrader.Indicator.MTFDataSeriesTest.OnBarUpdat e()


    PHP Code:
            protected override void Initialize()
            {
                
    ClearOutputWindow();
                
                
    Overlay                true;
                
    Add(PeriodType.Minute60);        //    BarsArray[1]
                
    BarsRequired 0;
                
                
    myDataSeries = new DataSeries(thisMaximumBarsLookBack.Infinite);          
            }

            
    /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            
    protected override void OnBarUpdate()
            {
                if(
    BarsInProgress == 0)
                {
                    
    //  Primary Series will be Daily Chart
    //                    Print(String.Format("BIP == 0:   CurrentBar: {0}   Time: {1}    Close: {2:0000.00}", CurrentBar, Time[0], Close[0]  ));
                
    }            
                
                if(
    BarsInProgress == 1)
                {
                    
    //  Secondary Series will be 60 Minute Chart
                    
    try
                    {
                        
    myDataSeries.Set(Close[0]);
    //                    Print(String.Format("\t\tBIP == 1    Bar: {0}  Time: {1}    {2:0000.00}",  CurrentBar, Time[0], myDataSeries[0]  ));
                    
    }
                    catch (
    Exception e)
                    {
                        Print(
    String.Format("BIP == 1:  Bar: {0}"CurrentBar  ));
                        Print(
    String.Format("Exception:  {0}"e  ));
                    }                
                }
            } 
    Any suggestions would be greatly appreciated.
    Last edited by TAJTrades; 03-24-2012, 07:20 AM.

    #2
    Originally posted by TAJTrades View Post
    I add a Secondary Series, 60 Minute to a Primary Daily, and then want to add DataSeries / IntSeries / BoolSeries to the Secondary Series.

    How do I get the DataSEries / IntSeries / BoolSeries to attach to the Secondary Series? The following code wants to attach to the Primary Series.

    The following code throws Exception:
    BIP == 1: Bar: 13
    Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    at System.Collections.ArrayList.get_Item(Int32 index)
    at NinjaTrader.Data.DataSeries.Set(Double value)
    at NinjaTrader.Indicator.MTFDataSeriesTest.OnBarUpdat e()


    PHP Code:
            protected override void Initialize()
            {
                
    ClearOutputWindow();
     
                
    Overlay                true;
                
    Add(PeriodType.Minute60);        //    BarsArray[1]
                
    BarsRequired 0;
     
                
    myDataSeries = new DataSeries(thisMaximumBarsLookBack.Infinite);          
            }
     
            
    /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            
    protected override void OnBarUpdate()
            {
                if(
    BarsInProgress == 0)
                {
                    
    //  Primary Series will be Daily Chart
    //                    Print(String.Format("BIP == 0:   CurrentBar: {0}   Time: {1}    Close: {2:0000.00}", CurrentBar, Time[0], Close[0]  ));
                
    }            
     
                if(
    BarsInProgress == 1)
                {
                    
    //  Secondary Series will be 60 Minute Chart
                    
    if (CurrentBars[1]  < 1) return;
                    try
                    {
                        
    myDataSeries.Set(Close[0]);
    //                    Print(String.Format("\t\tBIP == 1    Bar: {0}  Time: {1}    {2:0000.00}",  CurrentBar, Time[0], myDataSeries[0]  ));
                    
    }
                    catch (
    Exception e)
                    {
                        Print(
    String.Format("BIP == 1:  Bar: {0}"CurrentBar  ));
                        Print(
    String.Format("Exception:  {0}"e  ));
                    }                
                }
            } 
    Any suggestions would be greatly appreciated.
    Correction/addition is in the code.
    Last edited by koganam; 05-02-2014, 09:20 PM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by AaronKoRn, Today, 09:49 PM
    0 responses
    10 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Today, 08:42 PM
    0 responses
    9 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Today, 07:51 PM
    0 responses
    10 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,980 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Today, 06:48 PM
    0 responses
    9 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X