![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
Hello,
I've modified the SMAFromRangeBars file to an EMAFromMinuteBars file. I'm attempting to use more than one plot so I've added a second BarsInProgress series. Please tell me if I'm using "Inputs[1]" and "Inputs[2]" and "init" correctly. Code:
protectedoverridevoid OnStartUp()
{
average = EMA(Inputs[1],period);//private EMA
smoothedAverage = EMA(rawAverage,Smooth);//private EMA (DataSeries,int)
average2 = EMA(Inputs[2],period2);//private EMA
smoothedAverage2 = EMA(rawAverage2,Smooth);//private EMA (DataSeries,int)
init = false;
}
Code:
if(BarsInProgress == 0)//base chart
{
if (!init)//from OnStartUp
{
rawAverage.Set(Input[0]);
}
else
{
rawAverage.Set(avgValue);
}
if (!init2)//from OnStartUp
{
rawAverage2.Set(Input[0]);
}
else
{
rawAverage2.Set(avgValue2);
}
Value.Set(smoothedAverage[0]);
EMA2_from_timeBars.Set(smoothedAverage2[0]);
}
if (BarsInProgress == 1)
{
init = true;
avgValue = average[0];
}
if (BarsInProgress == 2)
{
init2 = true;
avgValue2 = average2[0];
}
Kirk |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
I also added this to the code in OnBarUpdate when I noticed it didn't plot at the higher timeframe:
Code:
if (CurrentBar < 21) return; |
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Kirk,
Inputs is not supported NinjaScript. Indicators have only one input series selection. Using Inputs won't provide any convenience for changing the input series of a secondary series. It will compile and produce a value, but the best practice is using Closes[1], Closes[2] in its place. http://www.ninjatrader.com/support/h...nstruments.htm
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
Thanks Ryan
|
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
Hello Ryan and others,
Can you please tell me how to plot this on tick charts? I've tested a couple things but no success yet. Thanks, Kirk |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Kirk,
For multiseries indicators, it's important to exclude processing until there are objects available. The following statement should help for this: if (CurrentBar < 0 || CurrentBars[1] < 0) return; If you are still running into issues, check the log tab of the control center for any error messages.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Senior Member
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
|
Hi Ryan,
you said: Quote:
Code:
if (CurrentBar < Period || CurrentBars[1] < Period) return; Kirk |
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
No, not necessarily. Checking for all CurrentBars[x] < 0 may be the minimum you want to do, but the actual values used will depend how your script is coded - If you reference prior bar values, exact calculations, etc.
These lines are designed to prevent NT from accessing objects that don't exist. To find exactly what's right for your script, try - catch blocks should be used to debug and find when it runs into this type of exception. http://www.ninjatrader.com/support/f...ead.php?t=9825
Ryan M
NinjaTrader Customer Service
Last edited by NinjaTrader_RyanM; 07-21-2011 at 01:16 PM.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Inputs[] | MikeInMA | General Programming | 3 | 09-03-2010 09:02 AM |
| No Commissions calculated despite inputs | tooearly | Strategy Analyzer | 3 | 07-04-2009 01:37 PM |
| User defined inputs | TedLincoln | ATM Strategies (Discretionary Trading) | 1 | 03-04-2009 02:26 PM |
| Inputs sorted alphabetically? | traderT | General Programming | 3 | 12-10-2008 09:17 AM |
| Too many inputs! | eDanny | Indicator Development | 6 | 07-25-2008 09:25 AM |