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 alifarahani, Today, 09:40 AM
          2 responses
          11 views
          0 likes
          Last Post alifarahani  
          Started by junkone, Today, 11:37 AM
          3 responses
          15 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by pickmyonlineclass, Today, 12:23 PM
          0 responses
          1 view
          0 likes
          Last Post pickmyonlineclass  
          Started by frankthearm, Yesterday, 09:08 AM
          12 responses
          44 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by quantismo, 04-17-2024, 05:13 PM
          5 responses
          35 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X