PDA

View Full Version : BarsInProgress > 0 DataSeries Operations


whitmark
07-15-2007, 10:45 AM
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:

...
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

NinjaTrader_Dierk
07-16-2007, 02:00 AM
How have you created the MTF1Signal data series?

whitmark
07-16-2007, 02:40 AM
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

#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);
...
}

NinjaTrader_Dierk
07-16-2007, 02:51 AM
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].

whitmark
07-16-2007, 03:00 AM
Okay . . . so how do I synchronize a dataseries with a BarsArray series other than 0? An example would be apprecated.

NinjaTrader_Dierk
07-16-2007, 03:01 AM
You can't.

whitmark
07-16-2007, 03:52 AM
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]?

...
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

NinjaTrader_Dierk
07-16-2007, 03:58 AM
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.