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

Custom IDataSeries in multi-timeframe

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

    Custom IDataSeries in multi-timeframe

    Hi, I have a custom BoolSeries, myBoolSeries, that has its value set when BarsInProgress == 1.


    I want to check its value when BarsInProgress == 0.


    Presumably, the following …


    Code:
    bool myValue = this.myBoolSeries[0];
    … won't work, as it will pick the value in BarsInProgress == 0.


    What will work instead?


    Thanks.
    Last edited by AnotherTrader; 04-29-2014, 08:36 AM.

    #2
    AnotherTrader,

    Thank you for your post.

    How are you setting the BoolSeries in the script?

    Additionally, how is it being synchronized as well? Usually in the Initialize()
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      ...

      How are you setting the BoolSeries in the script?

      Additionally, how is it being synchronized as well? Usually in the Initialize()

      Hi, Cal

      As below ...


      Code:
       
       
       #region Variables 
       private BoolSeries myBoolSeries; 
       #endregion
        
       protected override void Initialize()
       {
       this.myBoolSeries = new BoolSeries(this);
       }
        
        
       protected override void OnBarUpdate()
       {
       if (this.BarsInProgress == 0)
       { 
       bool myValue = this.myBoolSeries[0];??????
       }
       
       if (this.BarsInProgress == 1)
       { 
       this.myBoolSeries.Set(0, true);
       } 
       }





      Last edited by AnotherTrader; 04-29-2014, 11:09 AM.

      Comment


        #4
        Hi,

        Any further thoughts on this?

        Thanks.

        Comment


          #5
          AnotherTrader,

          There is a synchronization conflict with the logic. Since, BarsInProgress 1 is getting called first before the myBoolSeries has been set, it returns a default false. However, since BarsInProgress 1 gets called more often than BarsInProgress 2 does, it will try to create a new running instance of the myBoolSeries which is why you see the different results.

          You would need to run the myBool Series through a dummy indicator and then you would be able to set the new series to the added BarsArray in your logic.

          Instead of setting the synchronization in the Initialize you would set it the OnBarUpdate()
          Code:
          if(myBoolSeries == null)
          {
               myBoolSeries = new BoolSeries(dummyindicator(BarsArray[1]));
          }
          You can also check out the SampleDataSeries script from our forum page.
          http://www.ninjatrader.com/support/f...ead.php?t=3572
          Cal H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by PhillT, 04-19-2024, 02:16 PM
          4 responses
          31 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          36 views
          0 likes
          Last Post ageeholdings  
          Started by reynoldsn, Today, 02:34 PM
          0 responses
          10 views
          0 likes
          Last Post reynoldsn  
          Started by nightstalker, Today, 02:05 PM
          0 responses
          17 views
          0 likes
          Last Post nightstalker  
          Started by llanqui, Yesterday, 09:59 AM
          8 responses
          30 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Working...
          X