NexusFi: Find Your Edge


Home Menu

 





Placing Indicator Properties onto Strategy Properties Automagically


Discussion in NinjaTrader

Updated
    1. trending_up 1,326 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 6 attachments




 
Search this Thread

Placing Indicator Properties onto Strategy Properties Automagically

  #1 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
Posts: 12 since Jun 2014
Thanks Given: 9
Thanks Received: 12

The attached example shows how to automagically place indicator properties onto the property tab of the strategy. See attached images as well.

What the code shows is:
1. How to have indicator properties automatically on strategy properties
2. How to delete properties not required at that moment
3. How to update property names
4. How to update property descriptions

Comment: The last three aspects comes from the work discussed in this thread:


See following posts for more detail on how to use this and the situation within optimizer.

Fair warning: (a) this code is NOT for the faint of heart and (b) it works excellently, but still it is not what NinjaTrader developers might want you to do.

Attached Thumbnails
Click image for larger version

Name:	properties in chart.jpg
Views:	166
Size:	204.6 KB
ID:	161094   Click image for larger version

Name:	chart.jpg
Views:	158
Size:	211.6 KB
ID:	161095   Click image for larger version

Name:	properties in backtest.jpg
Views:	198
Size:	273.0 KB
ID:	161096   Click image for larger version

Name:	properties in optimizer.jpg
Views:	166
Size:	315.2 KB
ID:	161097   Click image for larger version

Name:	source example.jpg
Views:	168
Size:	473.3 KB
ID:	161098  
Attached Files
Elite Membership required to download: ExampleDynamicProperties.cs
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
  #3 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
Posts: 12 since Jun 2014
Thanks Given: 9
Thanks Received: 12


If you only wish to reflect the indicator properties onto your strategy, these are the key things that needs to be done in your strategy. See complete example attached to the first post for reference.

Add the ICustomTypeDescriptor interface onto your class, predefine your indicators so that they are class members and write a class constructor to "register" these indicators:
 
Code
  public class YourStrategy :	Strategy, ICustomTypeDescriptor
  {
    SMA  sma;
    MACD macd;

    public YourStrategy()
    {
      extraIndicators["SMA Filter"]   = sma  = SMA(200);
      extraIndicators["MACD Trigger"] = macd = MACD(12,26,9);
    }

In your initialize method, just Add these indicators as you normally do:
 
Code
  protected override void Initialize()
  {
    Add(sma);
    Add(macd);
  }

Add this empty method and cut-and-paste the "black magic" into your code:
 
Code
  private void ModifyProperties(PropertyDescriptor[] properties)
  {
  }

  #region Cut-And-Paste Boiler Plate Code
  ....
  #endregion
Have a coffee.

Started this thread Reply With Quote
  #4 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
Posts: 12 since Jun 2014
Thanks Given: 9
Thanks Received: 12

If you want to modify properties on the fly, the follow all the instructions above to get the code into your strategy. Thereafter, implement your logic into the method ModifyProperties.

The first is to delete properties which are not relevant at this moment. For example, if you set one property to say do only something simple, then you can dynamically remove the complex properties. It would look like this:
 
Code
  if (simpleMode)
    PropertyDelete(properties, "NameOfComplexProperty");

You can also change the name of the property. For example, in the optimizer, it happens sometimes that I need to know the range of values for a specific property. With this approach, I make the range as part of the property name. (The second example is easier achieved by statically setting the Gui.Design.DisplayName attribute.)
 
Code
  PropertyUpdateDisplayName(properties, "PropertyWithLimitedRange", "Property [0 --> 3]");
  PropertyUpdateDisplayName(properties, "PropertyDirection", "Direction [-1==short, +1==long]");

Similarly, you could update the property description to contain additional dynamic content:
 
Code
  PropertyUpdateDescription(properties, "PropertyWithUpdatedDescription", "Max value today is 7!");

Started this thread Reply With Quote
  #5 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
Posts: 12 since Jun 2014
Thanks Given: 9
Thanks Received: 12

OPTIMIZER: (The good, the bad and the UGLY)

What still does not work, is to have NinjaTrader step the indicator properties through a range. For the live of me, and after a few zillion hours of mucking around, I still don't understand when NinjaTrader decides that specific properties should have a range attached and when not.

I suspect that this part of the puzzle can only be resolved by having access to that piece of source code from the optimizer. As such, maybe on a rainy day, a developer from NT might give us the hint required.

Started this thread Reply With Quote




Last Updated on October 11, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts