![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jun 2008
Posts: 644
Thanks: 0
Thanked 0 times in 0 posts
|
Just wondering if something like this will work . So far these 2 lines don't
work . thx fastEma.Set(LinReg(Input, Fast)[2]); slowEma.Set(SMA(Input, Slow)[0]); |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
Hi there, are there any errors in the logs (right-most tab of Control Center)? Those two lines should work.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jun 2008
Posts: 644
Thanks: 0
Thanked 0 times in 0 posts
|
Error :
8/13/2009 8:17:17 AM Default Error on calling the 'OnBarUpdate' method for indicator 'MyMacdLregSMA2' on bar 0: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Not quite sure what that means ... Was trying on range chart . |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
On the first bar (bar 0), when you set this: fastEma.Set(LinReg(Input, Fast)[2]), the error you posted will occur because there is not enough data in the LinReg DataSeries. This tip applies here as well.
A solution would be to place this at the very beginning of OnBarUpdate(): Code:
protected override void OnBarUpdate()
{
// this NEEDS to be first
if (CurrentBar < 3)
return;
}
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jun 2008
Posts: 644
Thanks: 0
Thanked 0 times in 0 posts
|
Still problems . Maybe this will help ?
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
These are now different problems. The highlighted portions of the attached picture are not necessary.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jun 2008
Posts: 644
Thanks: 0
Thanked 0 times in 0 posts
|
Seems to be getting more complicated . ?
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
T2020, every bracket needs to have a "buddy" bracket. By that, I mean every { needs a }. In your attached picture, OnBarUpdate() has an opening bracket and two closing brackets. Thus, there is an imbalance and you will get compile errors.
If you remove the bracket below the Diff.Set line, you should be fine.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Jun 2008
Posts: 644
Thanks: 0
Thanked 0 times in 0 posts
|
I just noticed that .
Thanks again . |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Jun 2008
Posts: 644
Thanks: 0
Thanked 0 times in 0 posts
|
Here's the same indicator with an offset added to the slow line . It doesn't
plot ,so maybe this isn't going to work ??? |
|
|
|
|
|
#11 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Those brackets you are highlighting should not be there.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Jun 2008
Posts: 644
Thanks: 0
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#13 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You need to remove the brackets and then check your Control Center logs for errors.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#14 | |
|
Senior Member
Join Date: Jun 2008
Posts: 644
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
Parameter name: index what exactly does this mean ? |
|
|
|
|
|
|
#15 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Please change if (CurrentBar < 3) to be less than 4.
http://www.ninjatrader-support2.com/...ead.php?t=3170
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Stop mkt & stop limit w/offset in fast markets | VinnyB | SuperDOM and other Order Entry Windows | 2 | 06-05-2009 02:12 PM |
| Removal the MA lines from MACD | Armonistas | Indicator Development | 3 | 05-16-2009 01:03 PM |
| Quick MA an alternative to Juirk MA | Ninja B | Indicator Development | 5 | 01-09-2009 07:14 AM |
| MACD with up down arrows on MACD signal line crosses | moonriver | Indicator Development | 1 | 12-03-2008 10:34 AM |
| Hull MA of Macd Historigram | Learning1 | Indicator Development | 11 | 07-07-2007 01:25 PM |