NexusFi: Find Your Edge


Home Menu

 





NT8 Programming Help/Advice/Best Practices


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one NJAMC with 2 posts (9 thanks)
    2. looks_two dalebru with 2 posts (3 thanks)
    3. looks_3 poncho with 2 posts (0 thanks)
    4. looks_4 shodson with 1 posts (3 thanks)
    1. trending_up 5,596 views
    2. thumb_up 15 thanks given
    3. group 12 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

NT8 Programming Help/Advice/Best Practices

  #1 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395

With the public release of NT8, the Forum might get confusing as to which platform they are looking for programming help. I am starting this thread to help keep NT8 issues separate from NT7.

NT8 Now allows & Supports the following NinjaScript Type (FEEL THE POWER):
  • AddOns
  • BarsTypes
  • ChartStyles
  • DrawingTools
  • ImportTypes
  • Indicators
  • MarketAnalyzerColumns
  • OptimizationFitnesses
  • Optimizers
  • PerformanceMetrics
  • ShareServices
  • Strategies
  • SuperDomColumns

Given these features, there is very little you cannot do with NT8. I think we are going to see some clever solutions to some difficult problems come out of this new platform with the skills of the community.

This Thread I would like to put in place to help facilitate getting answers to questions:
  • How to?
  • Will it?
  • Best Practice?
  • XAML?
  • What is the best way?

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395


You may want to have only a single instance of a class within NT8 environment. Maybe this is a logging function or external IO. The following is a "Singleton Footprint" I found. Place this in your class instead of a constructor and replace "MyClassName" with the name of the class. Upon the first request for the "MyClassName.Instance" the class will be instantiated. Additional "MyClassName.Instance" will keep returning a reference to that same instance.

 
Code
#region Singleton Footprint		
	    private static readonly Lazy<MyClassName> lazy =
	         	new Lazy<MyClassName>(() => new MyClassName());
	     
	     public static MyClassName Instance { get { return lazy.Value; } }

	    private MyClassName()
	    {
                    }
#endregion
Inside your Indicator/Strategy or whatever you would normally have tried to create the "MyClassName" with something like this:
 
Code
     MyClassName   refClassName=new MyClassName();
Doing this with the proper Singleton Footprint will case a compiler error as "MyClassName()" is restricted as a Private constructor.

To get around this issue and use the Singleton properly, you will use the following line to get access to that singleton class:
 
Code
     MyClassName   refClassName= MyClassName.Instance;

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709

As NT8 is more multi-threaded, you may want to make your singleton classes multi-thread friendly. See this MSDN article on the Singleton Pattern.

Other popularly-used design patterns, all stemming from the publication of this famous book in 1994.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
dryg
France
 
Posts: 38 since May 2012
Thanks Given: 5
Thanks Received: 19

Is NT8 out already? Will they offer script translations from NT7? I use NT7 and after spending so much time to learn it I hope they will support it.

BTW, I am now testing the NinjaScript generation feature of Price Action Lab and I am wondering whether the following NT7 script will work in NT8:

 
Code
//Code starts here
#region Using declarations 
using System; 
using System.ComponentModel; 
using System.Diagnostics; 
using System.Drawing; 
using System.Drawing.Drawing2D; 
using System.Xml.Serialization; 
using NinjaTrader.Cbi; 
using NinjaTrader.Data; 
using NinjaTrader.Indicator; 
using NinjaTrader.Gui.Chart; 
using NinjaTrader.Strategy; 
#endregion 
 
namespace NinjaTrader.Strategy 
{ 
public class DIALONGT2S2Index35IndexDate20130313: Strategy
{ 
#region Variables 
 
#endregion 
protected override void Initialize() 
{ 
CalculateOnBarClose = true; 
} 
 
protected override void OnBarUpdate() 
{ 
if ( High[0] > High[1] &&  High[2] > Low[0] && High[1] > High[2] && Low[0] > Low[1] && High[3] > Low[2] && Low[1] > High[3] && Low[2] > Low[3] && Low[3] > Close[4] )
{
EnterLong(DefaultQuantity, "Long");
SetStopLoss("Long", CalculationMode.Percent,2*0.01, false);
SetProfitTarget("Long", CalculationMode.Percent,2*0.01);
}
}
 #region Properties
 
  #endregion 
}
}
 
//Code ends here
This works fine in NT7.

Reply With Quote
  #6 (permalink)
 dalebru 
Indianapolis/IN
 
Experience: Intermediate
Platform: SC, NT, ToS, my own
Broker: EdgeClear
Trading: ES
Posts: 67 since Jan 2013
Thanks Given: 1,035
Thanks Received: 110

NT8 is in public beta, so you can download it now. The code you show is not hard to convert, but I don't know if they will convert it for you.

Reply With Quote
  #7 (permalink)
 poncho 
Littleton, CO
 
Experience: Intermediate
Platform: Jigsaw (on NT8)
Broker: IB, IQFeed
Trading: CL
Posts: 12 since Oct 2015
Thanks Given: 13
Thanks Received: 14


NJAMC View Post
With the public release of NT8, the Forum might get confusing as to which platform they are looking for programming help. I am starting this thread to help keep NT8 issues separate from NT7.

NT8 Now allows & Supports the following NinjaScript Type (FEEL THE POWER):
  • AddOns
  • BarsTypes
  • ChartStyles
  • DrawingTools
  • ImportTypes
  • Indicators
  • MarketAnalyzerColumns
  • OptimizationFitnesses
  • Optimizers
  • PerformanceMetrics
  • ShareServices
  • Strategies
  • SuperDomColumns

Given these features, there is very little you cannot do with NT8. I think we are going to see some clever solutions to some difficult problems come out of this new platform with the skills of the community.

This Thread I would like to put in place to help facilitate getting answers to questions:
  • How to?
  • Will it?
  • Best Practice?
  • XAML?
  • What is the best way?

Since NT8 is still beta, there's a lot of work on NinjaScript to be done, acknowledged by the NT staff in their forums. AddOns in particular are not very well explained. There's basic examples on their help page about how to create tabbed windows, but not much else.

XAML is still a work in progress according to NT, they only support "loose" XAML, and you can't edit XAML within Visual Studio so I've read as it add Windows specific elements to the XAML that won't run in NT.

So far, I've found the best way to edit scripts is via Visual Studio since I am used to that IDE. However, if you have to manually create XAML files to add controls, that's going to suck. Maybe NT will change that before the final release.

Reply With Quote
  #8 (permalink)
 poncho 
Littleton, CO
 
Experience: Intermediate
Platform: Jigsaw (on NT8)
Broker: IB, IQFeed
Trading: CL
Posts: 12 since Oct 2015
Thanks Given: 13
Thanks Received: 14


dryg View Post
Is NT8 out already? Will they offer script translations from NT7? I use NT7 and after spending so much time to learn it I hope they will support it.

NT8 is still beta, no release date yet. There's a lot of code changes in NT8 (I am too new to add a link, Google 'code breaking changes ninjatrader' and look for the result to their forum). The biggest is that NT8 moved to WPF which changed a lot of the method calls and properties from NT7.

A lot of scripts won't work unless they are modified to run in NT8. NT staff is helping in the NT forums, you could try there if you have specific questions.

Reply With Quote
  #9 (permalink)
 dalebru 
Indianapolis/IN
 
Experience: Intermediate
Platform: SC, NT, ToS, my own
Broker: EdgeClear
Trading: ES
Posts: 67 since Jan 2013
Thanks Given: 1,035
Thanks Received: 110

A friend of mine has attached an auto-conversion script in the NinjaTrader Forum.
Here's a script to convert indicators and strategies - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

It might be useful.

Reply With Quote
Thanked by:
  #10 (permalink)
miansingle
Fayetteville NC USA
 
Posts: 5 since Sep 2013
Thanks Given: 0
Thanks Received: 0


Thanks for all the info! Great submission.

Reply With Quote




Last Updated on October 24, 2015


© 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