Placing Indicator Properties onto Strategy Properties Automagically - futures io
futures io



Placing Indicator Properties onto Strategy Properties Automagically


Discussion in NinjaTrader

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Placing Indicator Properties onto Strategy Properties Automagically

(login for full post details)
  #1 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
 
Posts: 12 since Jun 2014
Thanks: 9 given, 12 received

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:	58
Size:	204.6 KB
ID:	161094   Click image for larger version

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

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

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

Name:	source example.jpg
Views:	67
Size:	473.3 KB
ID:	161098  
Attached Files
Register to download File Type: cs ExampleDynamicProperties.cs (17.1 KB, 17 views)
Started this thread Reply With Quote
The following 4 users say Thank You to zr6bcm for this post:

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(96 thanks from 15 posts)
looks_twoSalao's Journalby Salao
(32 thanks from 7 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(26 thanks from 11 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(13 thanks from 8 posts)
looks_5Maybe a little bit different journalby Malykubo
(9 thanks from 8 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Would You Sell Your System?
73 thanks
The Crude Dude Oil Trading System
40 thanks
Big Mike in Ecuador
39 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
24 thanks
futures io site changelog and issues/problem reporting
24 thanks
 
(login for full post details)
  #3 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
 
Posts: 12 since Jun 2014
Thanks: 9 given, 12 received


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
 
(login for full post details)
  #4 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
 
Posts: 12 since Jun 2014
Thanks: 9 given, 12 received

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
 
(login for full post details)
  #5 (permalink)
 zr6bcm 
Heidelberg, Germany
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
 
Posts: 12 since Jun 2014
Thanks: 9 given, 12 received

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


futures io Trading Community Platforms and Indicators NinjaTrader > Placing Indicator Properties onto Strategy Properties Automagically


Last Updated on October 11, 2014


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts