Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsInProgress > 0 DataSeries Operations

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

    BarsInProgress > 0 DataSeries Operations

    I am working on a multiple-timeframe strategy that uses three timeframes in all and has some fairly envolved logic for each. Once I resolve each timeframe's partial trading signal, I hope to push this value (or related values) to its own data series such that I can evaluate the conditions (for the current bar and previous bars) across all timeframes before submitting a trade as follows:

    Code:
    ...
    if (BarsInProgress == 0)
    {
        if (ThisComplexTimeFrame0LogicTrue)
            MTF1signal.Set(1);
    }
    if (BarsInProgress == 1)
    {
        if (ThisComplexTimeFrame1LogicTrue)
            MTF2signal.Set(1);
    }
    if (BarsInProgress == 2)
    {
        if (ThisComplexTimeFrame2LogicTrue)
            MTF3signal.Set(1);
    }
    ...
    if (BarsInProgress == 0)
    {
         if (MTF1signal[0] == 1 &&
             MTF1signal[1] !=  1 &&
             MTF2signal[0] == 1 &&
             MTF2signal[1] !=  1 &&
             MTF3signal[0] == 1 &&
             MTF3signal[1] !=  1 )
         {
            EnterLong();
         }
    }
    ...
    In this context, I would think that the reference to MTF3signal[0] would be the last value I set when BarsInProgress == 2. However, I am getting results that suggest that DataSeries collections are only available for the BarsArray[0] series. Please confirm.

    While in a BarsInProgress = 0 event, is there a way to get dataseries values that where set during other BarsInProgress events? if I can't get this to work, I will likely substitute the dataseries with private variables, arrays, or queues.

    Regards,

    Whitmark
    Last edited by whitmark; 07-15-2007, 10:51 AM.
    whitmark
    NinjaTrader Ecosystem Vendor - Whitmark Development

    #2
    How have you created the MTF1Signal data series?

    Comment


      #3
      Yes, please see below. I have since moved on and used private variables as substitutes for these signal dataseries, but would like to understand how this can work for future reference when the signal lookback might be more than just one bar back. Thanks.

      Whitmark

      Code:
      #region Variables
      ...
      DataSeries MTF1signal;
      DataSeries MTF2signal;
      DataSeries MTF3signal;
      ...
      #endregion
      
      protected override void Initialize()
      {
           ...
           MTF1signal = new DataSeries(this);
           MTF2signal = new DataSeries(this);
           MTF3signal = new DataSeries(this);
           ...
      }
      whitmark
      NinjaTrader Ecosystem Vendor - Whitmark Development

      Comment


        #4
        I see. The CurrentBar index of the series then is in sync with BarsArray[0], meaning MTF3signal[0] "points" to the same index as BarsArray[0][0].

        Comment


          #5
          Okay . . . so how do I synchronize a dataseries with a BarsArray series other than 0? An example would be apprecated.
          whitmark
          NinjaTrader Ecosystem Vendor - Whitmark Development

          Comment


            #6
            You can't.

            Comment


              #7
              Alright . . . for clarification then, if I am setting signal values into MTF2signal and MTF3signal dataseries when BIP = 1 and BIP = 2 occur respectively . . . and then comes a long a BIP = 0 event, do the previously set values for MTF2signal and MTF3signal get pushed to the [1] slot when the next BarArray[0] bar prints?

              If so, in the example context, would this suggest the modified composit trade signal logic would be more appropriate realizing that it is synchronized to BarArray[0]?

              Code:
              ...
              if (BarsInProgress == 0)
              {
                   if (MTF1signal[0] == 1 &&
                       MTF1signal[1] !=  1 &&
                       MTF2signal[1] == 1 &&
                       MTF2signal[2] !=  1 &&
                       MTF3signal[1] == 1 &&
                       MTF3signal[2] !=  1 )
                   {
                      EnterLong();
                   }
              }
              ...
              Clearly, the modified code above is not what I had originally intended but hopefully useful to fleshout the point. Do you recommend the use of an alternative data collection type that allows the same FIFO value setting capability, supports bars ago referencing for a limited lookback period, and can be synchronized (or set) to each BIP event? Just looking for a directional answer on this one. Thanks.

              Regards,

              Whitmark
              whitmark
              NinjaTrader Ecosystem Vendor - Whitmark Development

              Comment


                #8
                Let me try to clarify: There is a CurrentBar "pointer" for any bar series and your data series below is just in sync with the the "primary" bar series: whenever the CurrentBar "pointer" for the primary series is moved, then the CurrentBar "pointer" for your series is moved.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                558 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X