NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 09-21-2011, 11:36 AM   #1
nicbizz
Senior Member
 
Join Date: Jun 2010
Posts: 129
Thanks: 17
Thanked 6 times in 4 posts
Default Using indicator parameters in Strategy

This follows from the Tutorial 2 sample strategy in the Help Guide (i.e. RSI with a Stop Loss and a Profit Target).

Our entry condition is this:

Code:
if (CrossAbove (RSI(RSIPeriod, RSISmooth), 20, 1))
{
EnterLong();
}
Instead of setting a new RSIPeriod for the strategy, I'd like to use the Period parameter from the RSI indicator, that is added during the Initialize() phase of the Strategy.

How do I got about referencing it?

Thanks!
nicbizz is offline  
Reply With Quote
Old 09-21-2011, 11:45 AM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello nicbizz,

Your strategy should control all the input parameters in this case.

You can use the same variable name for both places: 1) adding the indicator for visualization in initialize 2) evaluating indicator values in OnBarUpdate() for an order condition. This is what is shown in the example.

You can access the indicator "Period" value but there is no benefit to this. Since the user never has access to this indicator input when running the strategy, it will always be the default value for Period in the RSI indicator.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 09-21-2011, 06:17 PM   #3
nicbizz
Senior Member
 
Join Date: Jun 2010
Posts: 129
Thanks: 17
Thanked 6 times in 4 posts
Default

Hi Ryan,

THanks for the reply.

Perhaps this is not the best example to illustrate what I'm attempting to do.

Let's say I have a custom indicator called IndicatorX, which has a public property called PricePoint.

If I'd like to reference the value of PricePoint in my strategy, what is the correct syntax to do so?

In regular C#, I'd have to create an instance of IndicatorX .....

IndicatorX thisIndicator = new IndicatorX();

and then call the property using thisIndicator.PricePoint.

-Nick
nicbizz is offline  
Reply With Quote
Old 09-21-2011, 10:56 PM   #4
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,219
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by nicbizz View Post
Hi Ryan,

THanks for the reply.

Perhaps this is not the best example to illustrate what I'm attempting to do.

Let's say I have a custom indicator called IndicatorX, which has a public property called PricePoint.

If I'd like to reference the value of PricePoint in my strategy, what is the correct syntax to do so?

In regular C#, I'd have to create an instance of IndicatorX .....

IndicatorX thisIndicator = new IndicatorX();

and then call the property using thisIndicator.PricePoint.

-Nick
That is one way to do it.
koganam is offline  
Reply With Quote
Old 09-23-2011, 08:17 AM   #5
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Nicbizz,

Yes, that is how you would do it. Can see this sample for best practices on exposing non-plot value from another indicator:
http://www.ninjatrader.com/support/f...ead.php?t=4991
NinjaTrader_RyanM 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
Passing parameters from Strategy to Indicator via Add() abfc123 Indicator Development 1 11-09-2010 05:52 AM
When indicator parameters not in Parameters category MikeInMA Strategy Development 3 11-08-2010 03:24 PM
Indicator Accessing Indicator Where User Has Set Parameters dkrumholz Indicator Development 1 04-27-2010 02:56 PM
Indicator Parameters in a Strategy laocoon Strategy Development 1 10-08-2009 04:11 AM
Indicator parameters from within a strategy astrolobe Indicator Development 1 06-20-2009 11:05 PM


All times are GMT -6. The time now is 11:06 AM.