View Full Version : Accessing variable from a 5min Indicator and 15min Indicator
mefTrader
01-11-2010, 01:22 PM
Having Read the following link about accessing Indicator variables ina Strategy on the same chart
http://www.ninjatrader-support2.com/vb/showthread.php?t=4991
I have an instance of my indicator('my_ind') in Market Analyzer on 5min chart(effectively) and an instance of the same indicator added again and set to 15min...
What is the is the instance name on 5min chart and 15min chart?
or does it have the same name and do I need to differentiate the variable names like the folowing in my sole indicator 'my_ind'
my_ind().var5[0] == 0;
my_ind().var15[0] == 0;
where 'var5' and 'var 15' are set based on
if ((Bars.Period.Id == PeriodType.Minute) && (Bars.Period.Value == 5) )
{
//set 'var5' here
}
?
NinjaTrader_Josh
01-11-2010, 02:43 PM
The name would be the same. The way to differentiate them is to use the BarsArray.
my_ind(BarsArray[1]).someValue
versus
my_ind(BarsArray[2]).someValue
mefTrader
01-11-2010, 03:09 PM
so if the variable is say 'Trend' in the indicator 'my_ind' then to set to the following variable(sum) on 5min chart only would look like;
if ((Bars.Period.Id == PeriodType.Minute) && (Bars.Period.Value == 5) )
{
Sum.set [0] = my_ind(BarsArray[0]).Trend[0] + my_ind(BarsArray[1]).Trend[0];
//sum 5 and 15min Trend values on the 5min timeframe
}
mefTrader
01-11-2010, 03:16 PM
or I could write it as
if ((Bars.Period.Id == PeriodType.Minute) && (Bars.Period.Value == 5) )
{
Sum.set [0] = Trend[0] + my_ind(BarsArray[1]).Trend[0];
//sum 5 and 15min Trend values on the 5min timeframe
}
What happens when the indicator can not find 15min data or other time frame - say I put the indicator just on a 5min chart alone and not in the market analyzer as two instances(5min, 15min) do I have to do a check on BarsArray? HOw do I do that?
NinjaTrader_Josh
01-11-2010, 03:27 PM
mefTrader,
Not sure I follow what you mean. You can only access multi-time framed values from a NinjaScript Strategy. From a NinjaScript strategy you add the various time frames you want to use and then you just access the indicator based on the time frame you are looking for. This is achieved through BarsArray[]. Please see this article as it may help: http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?MultiTimeFrameInstruments
mefTrader
01-12-2010, 05:17 AM
So how do I access multiple instances of indicators in a Market Analyzer?
my_ind is added as a instance and the minute =5
my_ind is added again as another instance and the minute is set to 15
NinjaTrader_Bertrand
01-12-2010, 05:40 AM
mefTrader, this is not possible for indicators in NinjaTrader 6.5 - only strategies have the option to work with multiple series / multiple timeframes in NinjaTrader 6.5
http://www.ninjatrader-support.com/HelpGuideV6/MultiTimeFrameInstruments.html
For NinjaTrader 7 we extented this concept to indicators as well, as we then have MultiSeries charting capabilities.
http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html
mefTrader
01-12-2010, 06:09 AM
ok what is the release date of NT7?
NinjaTrader_Bertrand
01-12-2010, 09:14 AM
We're currently in beta and successfully working on resolving reported issues - a public beta should follow shortly - when this would be the case and all other related details can be found here -
http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html