NinjaTrader Support Forum  

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 07-06-2007, 01:51 PM   #1
JangoFolly
Member
 
Join Date: Nov 2006
Location: , ,
Posts: 73
Thanks: 0
Thanked 0 times in 0 posts
Default Passing period parameter to Add function as a variable

Hi. I tried to pass an integer value to the Add function to populate the period parameter, but it did not work.


// where my_int is declared as a int variable
my_int = 5;

Add(PeriodType.Minute, my_int);


Is there a way to accomplish the goal of calling Add with a variable value for period, rather than a static constant?

Thank you.


Regards,

William
JangoFolly is offline  
Reply With Quote
Old 07-06-2007, 02:01 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Provided that the variable value my_int is the value you want prior to using it in the Add() method, this will work.

Try adding a Print(my_int) just before calling the Add() method to ensure the value is initialized as you expect.
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-08-2007, 06:47 PM   #3
gert74
Member
 
Join Date: May 2007
Posts: 35
Thanks: 0
Thanked 0 times in 0 posts
Default

Am I right in assuming that there is no way to use user supplied inputs in the Add method, as they are not available yet when Initialize is called?
gert74 is offline  
Reply With Quote
Old 07-08-2007, 07:02 PM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

You can use user inputs (properties) in the Add() method called within the Initialize() method.
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-23-2007, 10:37 AM   #5
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

Ray,

Could you please clarify your statement:

Quote:
You can use user inputs (properties) in the Add() method called within the Initialize() method.
Is it possible to pass in a value via parameter inputs, define the period of the Add() method, and then iterate these values via the optimizer in the Strategy Analyzer? It appears the process to pass in this period value works in a Chart and when backtesting, but not during optimization operations. Please confirm.

Regards,

Whitmark
whitmark is offline  
Reply With Quote
Old 07-23-2007, 10:44 AM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

I have never tried that in optimization. If you have and it does not work, then that is current expected behaviour.
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-23-2007, 10:59 AM   #7
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

As you can image, it can be pretty handy to use the optimizer to get a feel for the right combination of multiple timeframes or, for that matter, multiple instruments (enumerated of course) to be used within a strategy. Can we consider this for the enhancement list? Thanks.

Whitmark
whitmark is offline  
Reply With Quote
Old 07-23-2007, 01:59 PM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Yes, this is already on our list.
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-06-2007, 08:14 AM   #9
MONTERO
Junior Member
 
Join Date: Aug 2007
Posts: 8
Thanks: 0
Thanked 0 times in 0 posts
Talking

Do you know which version and when the ETA is? I am very interested in this.
MONTERO is offline  
Reply With Quote
Old 08-06-2007, 08:38 AM   #10
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Unfortunately there no ETA available yet.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 05-10-2008, 02:56 PM   #11
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

Has the ability to pass in the PeriodType and Period Size for a secondary series via a parameter AND allow these parameters to be iterated in the optimizer been considered yet for Version 7? Thanks.

Whitmark
whitmark is offline  
Reply With Quote
Old 05-10-2008, 04:32 PM   #12
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Thanks for the note whitmark. We will put it on the list for considerations.
NinjaTrader_Josh 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
Swing Indicator Strength parameter Kardinal Charting 1 07-06-2007 09:10 AM
Example for passing Time/Date as a Parameter zoltran General Programming 7 05-17-2007 09:32 AM
Parameter selection lists ThePatientOne Indicator Development 3 05-11-2007 08:48 AM
Parameter sorting/ordering rtrader Suggestions And Feedback 3 04-08-2007 05:27 PM
Tradestation - passing in Account Numbers jonno Automated Trading 1 12-20-2005 05:59 AM


All times are GMT -6. The time now is 09:22 PM.