![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
My users are creating NinjaScript strategies, and they are creating custom parameters for their strategies that look something like this in the C# code: privateint ticksBetter = 1; [Description("Ticks Better is used to do such-and-such.")] [Category("Parameters")] publicint TicksBetter { get { return ticksBetter; } set { ticksBetter = Math.Max(0, value); } } I am looking for a way to iterate over all user-created custom parameters so that I can write this information out to a database. Using intellisense inside of a strategy, I can't find a collection like "this.Parameters". Is there a collection that holds these parameters that I can iterate over in C# code? Thanks in advance! ChiTrader2000 |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Unfortunately ChiTrader2000, this is not supported.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
ChiTrader2000, it's not just not supported by NT, but there is no concept in C# which provides collections for methods, variables or properties automatically. Guess you have to collect it by your own.
Regards Ralph |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
Thanks for the information. I will just write it myself using C# Reflection. Thanks again, ChiTrader2000 |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
Just an idea for coding. Instead of using private variables like:
private int ticksBetter = 1; you could use the desired (and self-designed) collection as source the properties are reading from, and as target the properties are writing to. This way your collection is always up-to-date without additional coding required. Regards Ralph |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
Hello Ralph,
That's a great way to do it without using System.Reflection. Problem solved! Thanks again! ChiTrader2000 |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jan 2009
Posts: 423
Thanks: 25
Thanked 11 times in 10 posts
|
Hi there:
Alright, I'm fairly new to NT and only started to code in C# but I have been coding in Java for over 12 years. Take a look at this: http://www.developer.com/java/other/article.php/2114451 In Java it's possible to use 'introspection' to dynamically retrieve a class' parameters and then loop through them. The article covers both Java and C#. Good luck! Michael |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
|
Can you tell us what function is called to get the Parameter name string that is displayed in the chart, or in the Parametesr column of the strategies tab?
|
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
|
Never mind, me and my seemingly limitless genious has figured it out!
public string getParameterString() { string parameterString = ""; foreach( NinjaTrader.Strategy.Parameter parameter in this.Parameters) { parameterString += "( "; parameterString += parameter.Name; parameterString += " = " + parameter.Value; parameterString += " ) - "; } return parameterString; } |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Note: this is a area which is beyond what we provide support for. Please be aware that the undocumented features you're using might be gone or work differently on next NT version/release.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
|
When's that? Approx?
|
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
There is no set release date. We are hoping to get it into Beta testing within a few months.
Ben
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Add to ATM Strategy "Trailing "Limit"" | shawnj | Suggestions And Feedback | 2 | 10-10-2008 08:01 PM |
| Can "workspaces" be created for charts? | bluelou | Charting | 9 | 07-18-2008 08:31 AM |
| "'OrderRejected'. Strategy has sent cancel requests" & "There is no market data..." | Elliott Wave | Strategy Development | 6 | 04-12-2008 12:03 AM |
| 2 instances of strategy when clicking "apply" and "okay" | dtf139 | Historical NinjaTrader 6.5 Beta Threads | 2 | 01-07-2008 11:25 PM |
| SuperDOM Window with "Always On Top" created deadlock | jwalker | Miscellaneous Support | 1 | 05-19-2005 03:49 PM |