![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Nov 2007
Posts: 63
Thanks: 0
Thanked 0 times in 0 posts
|
Hello everyone,
I have read every single existing thread on this topic but I still have not found a solution to my problem. Here it is: I have created a multi-timeframe indicator called ContextAnalyzer. This indicator performs an analysis of two timeframes and populates a DataSeries object (myContextSeries) with the results of the analysis (a single value for each bar of the primary data series). I have completely tested this indicator and it works like a charm when applied to a chart. I have even done as far as printing the CurrentBar and myContextSeries[0] for each bar of the primary series to verify the logic. So far, so good.... myContextSeries is exposed publicly via the following code: [Browsable(false)] [XmlIgnore()] public DataSeries ContextMOM { get { return myContextSeries; } } So far I assume that all is good... I would now like to use the values of the DataSeries referenced above in another indicator, let's call it ContextConsumer. Here is my test code for this: Code:
public class ContextConsumer: Indicator
{
private ContextAnalyzer myContext;
protected override void Initialize()
{
Overlay = true;
}
protected override void OnStartUp()
{
myContext = ContextAnalyzer(PeriodType.Minute,3);
}
protected override void OnBarUpdate()
{
double dContext = myContext.ContextMOM[0];
if (dContext == -2) BarColor = Color.Red;
if (dContext == -1) BarColor = Color.Magenta;
if (dContext == 1) BarColor = Color.LightBlue ;
if (dContext == 2) BarColor = Color.Blue ;
}
Any help is greatly appreciated. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
|
Hello,
Thanks for your forum post. When using multi series and data series objects. You must sync the data series to the object it will be tracking. Please see this guide: http://www.ninjatrader.com/support/f...ead.php?t=3572 Let me know if I can be of further assistance.
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Nov 2007
Posts: 63
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Brett,
I have already read that post several times and my code is in line with it. The DataSeries myContextSeries is correctly synchronized to the primary series in ContextAnalyzer. I didn't create a secondary series for the other timeframe since I didn't have any use for it. Is any synchronization required in the calling indicator "ContextConsumer" required? David |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
David,
Not exactly sure what you are doing. We do not support this "ContextAnalyzer" object you are calling nor would have any idea what it is. DataSeries are only able to sync to DataSeries as outlined in the reference sample. You can do one of the following: 1. In Initialize() you call someDataSeries = new DataSeries(this); The "this" reference syncs it to the primary bars. 2. In OnBarUpdate() you can sync to a secondary bars series. someDataSeries = new DataSeries(SMA(BarsArray[1], 50)); The BarsArray[1] is what the someDataSeries is synced to. You are doing neither of the above.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Nov 2007
Posts: 63
Thanks: 0
Thanked 0 times in 0 posts
|
Josh - there is a similar thread here: http://www.ninjatrader.com/support/f...622#post213622
ContextAnalyzer is simply my indicator, mentioned in this thread as an example. This indicator uses a second timeframe to perform an analysis and saves the results of this analysis in a DataSeries object. This works perfectly fine. The problem that I am facing however, is when trying to use this DataSeries from yet another indicator that only has primary bars. When doing this, the values returned by the DataSeries of ContextAnalyzer are all wrong. In the other thread, snaphook seems to be experiencing the exact same problem. I do not believe that the example that you provide with the secondary dataseries that is synced in OnBarUpdate() has any bearing on this problem. |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
|
Trader,
Just so that I understand correctly. Your trying to use variables from another indicator in another indicator or strategy? Therefor your trying to do communication between strategies/indicators? I look forward to assisting you further.
Brett
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dataseries problem in Multi-timeframe strategy | bridenour | Automated Trading | 2 | 07-25-2009 05:06 AM |
| Multi timeframe dataseries | astrolobe | Strategy Development | 1 | 06-17-2009 05:47 AM |
| Multi-timeframe indicator referencing | LazKz | Strategy Development | 3 | 03-18-2009 07:24 AM |
| DataSeries on supplementary series in multi-timeframe strategy | DavidD99 | Strategy Development | 1 | 11-30-2008 03:39 AM |
| Referencing DataSeries elements in Multi-timeframe Strategies | dbw451 | Strategy Development | 2 | 09-06-2008 09:17 AM |