![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Certified NinjaScript Consultant
|
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();
}
}
...
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 at 10:51 AM.
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
How have you created the MTF1Signal data series?
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Certified NinjaScript Consultant
|
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);
...
}
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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].
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Certified NinjaScript Consultant
|
Okay . . . so how do I synchronize a dataseries with a BarsArray series other than 0? An example would be apprecated.
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
You can't.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Certified NinjaScript Consultant
|
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();
}
}
...
Regards, Whitmark |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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.
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Exposing non dataseries variable | tquinn | General Programming | 10 | 05-17-2007 04:12 PM |
| Meaning of Message: Order was placed in incorrect 'BarsInProgress' context? | plipa | Strategy Development | 9 | 04-22-2007 08:54 AM |
| Hiding a plotted DataSeries in an indicator | tquinn | Indicator Development | 7 | 01-13-2007 11:42 AM |
| Exposing a non DataSeries property in an indicator | tquinn | Indicator Development | 4 | 01-11-2007 02:29 PM |