NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 06-17-2010, 07:00 AM   #1
cgeorgan
Senior Member
 
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
Default Basic question: Indicator on an Indicator

Hello-

I'm new to NinjaTrader, but not new to programming in C# (I'm working here to port some indicators I wrote in NeoTicker to NinjaTrader).

My question involves Ninja Trader's protocol when writing an indicator on an indicator. In this case, the example would be creating a Moving Average on Momentum, which itself is based on a calculated data series.

I'm not sure if NinjaTrader allows nested indicators, but here's what I've been doing:

Code:
double myValue = Math.Log(System.Convert.ToDouble(Close[0]));
            
            logSeries.Set(myValue);
            
            momentumSeries.Set(Momentum(logSeries, 1)[0] * 100);
            
            M_EMA_1.Set(EMA(momentumSeries, 10)[0]);
So you can see there I created a value that's really just the LN of the closing value; I then set those values to a data series to be used by Momentum. I get caught up when I try and use that momentumSeries later in an EMA calculation.

Where am I screwing up, and is this even possible?
cgeorgan is offline  
Reply With Quote
Old 06-17-2010, 07:06 AM   #2
cgeorgan
Senior Member
 
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
Default Addendum

I tried the following:

Code:
logSeries.Set(Math.Log(System.Convert.ToDouble(Close[0])));
            
            momentumSeries.Set(Momentum(logSeries, 1)[0] * 100);
            
            M_EMA_1.Set(EMA(momentumSeries, LT_ROC_EMA_Period)[0]);
Obviously logSeries and momentumSeries are DataSeries types. The code above does not result in any output.

As an aside, how can I debug (set break points) in the NinjaScript editor, or do I load up the .CS project in Visual Studio and wait for Ninja to call it?
cgeorgan is offline  
Reply With Quote
Old 06-17-2010, 07:47 AM   #3
NinjaTrader_Tim
NinjaTrader Customer Service
 
NinjaTrader_Tim's Avatar
 
Join Date: Nov 2009
Location: Denver, CO
Posts: 1,424
Thanks: 0
Thanked 3 times in 3 posts
Default

Hi cgeorgan,

Welcome to NinjaTrader and to the forum.

Nesting the dataseries within an indicator should be no problem.

First, please take a look at this page from our help guide for the necessary steps to properly create a data series.
Page at - http://www.ninjatrader-support.com/H...culationLogic2
Sample at - http://www.ninjatrader.com/support/f...ead.php?t=7299

Also, check your Log tab in the Control Center while running the indicator, for any errors.

As for debugging, you could certainly open the script in VS, or you can use Print() statements or Try/Catch blocks within NinjaTrader.
Print()'s - http://www.ninjatrader.com/support/f...ead.php?t=3418
Try/Catch - http://www.ninjatrader.com/support/f...ead.php?t=9825
NinjaTrader_Tim is offline  
Reply With Quote
Old 06-21-2010, 02:35 PM   #4
cgeorgan
Senior Member
 
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
Default

Thanks guys, taking a little time but getting up to speed.
cgeorgan is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem: basic indicator starts only on 21st bar of a daily chart CycleArt Charting 2 06-01-2010 02:05 PM
Basic indicator scaling question jtrade Charting 2 02-01-2010 06:29 AM
Please help me with this basic indicator suprsnipes NinjaScript File Sharing Discussion 1 11-06-2009 05:40 AM
Can anyone help add a .wav file for alerts to this basic indicator bigmama General Programming 9 10-31-2009 12:33 AM
Basic Question. Drakmyre Strategy Analyzer 2 08-31-2008 11:03 PM


All times are GMT -6. The time now is 12:31 PM.