NexusFi: Find Your Edge


Home Menu

 





Some coding practices when using VS with NinjaTrader


Discussion in NinjaTrader

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




 
Search this Thread

Some coding practices when using VS with NinjaTrader

  #1 (permalink)
 BMMA14 
Montreal,Quebec/Canada
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Forex
Posts: 17 since Jun 2014
Thanks Given: 5
Thanks Received: 15

Hi everyone

I have recently joined BigMike's forum and I would like to contribute some of my experiences in using Visual Studio along with NinjaTrader. Some of these have been possibly mentioned by other forum users before, nevertheless if so I hope that's ok.

I have been experimenting with Ninjatrader for a short while. My aim was to be able to call a class library from NT script. By error & trial(note that I used some forum discussions and tips as well), I came upon some steps that needs to be taken carefully, in order for a script to work properly. Below I would like to share the conclusions of some of my experiences.

1-Always compile your class libraries into c>users....>MyDocuments>NinjaTrader7>bin>Custom. If compiled somewhere else, it works sometimes but not all the time. I don't know the internals of NT well enough to explain this.
2-Place your project under the same directory. (I am using Win7 pro)
3-Use Net 3.5 for your class library.
4-Create the template of your indicator always in NT (NT creates bunch of extra C# code)
5-When adding your indicator into VS project add it as "Link"

These are the ones coming into my mind at the moment. Feedback/corrections are welcome and I hope it may help others.

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
33 thanks
Tao te Trade: way of the WLD
24 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
11 thanks
GFIs1 1 DAX trade per day journal
11 thanks
  #2 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

Would be very interested in learning about some of your applications of these techniques.

I don't know if this would be one, but I would like to be be able to use an object that is just like the DataSeries object, but has a fixed, user defined number of elements - with a fixed element count, it could be based on the C# array, rather than the list.

This would be perfectly adequate for many places where the DataSeries is used, with a big reduction in memory and CPU consumption since the number of elements to be managed would often be much less than 256, and much less than the number of bars on the chart.

Another worthy goal would be the ability to create an object that works just like an instrument but is based on the weighted sum of more than one instrument. Yes, this can be done in an indicator, but having something that behaves just like a regular instrument would have some advantages.

(While I am good at making Ninjatrader indicators run efficiently, my mastery of C# is narrow and limited.)

"If we don't loosen up some money, this sucker is going down." -GW Bush, 2008
“Lack of proof that something is true does not prove that it is not true - when you want to believe.” -Humpty Dumpty, 2014
“The greatest shortcoming of the human race is our inability to understand the exponential function.”
Prof. Albert Bartlett
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 BMMA14 
Montreal,Quebec/Canada
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Forex
Posts: 17 since Jun 2014
Thanks Given: 5
Thanks Received: 15


For anyone reading this thread, there is another thread which I would like to re-iterate here. The thread is called NT & VS for Dummies and includes very useful information. Check it out ( )

Secondly, I managed to crash today NT completely. Well, this may be one of the side effects of using Visual Studio. You got to be very careful, especially with NT DLLs (like .Core), meaning where you place them etc. I am planning to write a thorough document for myself, in order to follow it up at the next crash. I will post it here as well, for anyone willing to use it as a first aid reference. Coming back to today's crash. I was copying some existing classes into my class library (the one I am using in my indicator). The classes I imported required NT DLLs as reference. As sson as I imported the DLLs into th reference of the library project, boom sth. happened and the next time I hit F5, NT wasn't launching. I couldn't even launch NT standalone. Error log was directing me to NinjaTrader.Core.DLL. I had to totally scrap NT from my computer (yes, uninstalling first thru windows and then completely erasing all leftover NT Folders from Windows Explorer). My assumption is that possibly I have referenced a copy of the NT Core DLL which was residing somewhere else in my computer (It dawned on me, after I wiped out NT though). So the lesson learned is: When using NT along with VS, one should be extremely tedious and keep all the references in a VS solution same (meaning you only use one NT DLL location). Tomorrow I will go through the process again to link NT back to my class library (following the post listed above).
Tomorrow I will also try to use a static class within my class library to see if it works. The reason being is that I would like to pass variables to and from my main C# business model to NT without the need of class instantiation. That would remove the need of passing class object reference. Well, I'll see how it will work.

Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 BMMA14 
Montreal,Quebec/Canada
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Forex
Posts: 17 since Jun 2014
Thanks Given: 5
Thanks Received: 15


Zondor View Post
Would be very interested in learning about some of your applications of these techniques.

I don't know if this would be one, but I would like to be be able to use an object that is just like the DataSeries object, but has a fixed, user defined number of elements - with a fixed element count, it could be based on the C# array, rather than the list.

This would be perfectly adequate for many places where the DataSeries is used, with a big reduction in memory and CPU consumption since the number of elements to be managed would often be much less than 256, and much less than the number of bars on the chart.

Another worthy goal would be the ability to create an object that works just like an instrument but is based on the weighted sum of more than one instrument. Yes, this can be done in an indicator, but having something that behaves just like a regular instrument would have some advantages.

(While I am good at making Ninjatrader indicators run efficiently, my mastery of C# is narrow and limited.)

Once in VS, anything can be done (well that what I assume at the moment at least). My approach is to use NT script with minimum code and use class libraries to do what I would like to do. So NT Script is just a front end which provides some basic info to my business model running in the background. I will only post some annotations on chart display reflecting the computed outcome of the background machine. Therefore I need a very stable link in between my VS Class libs and NT.

Started this thread Reply With Quote




Last Updated on August 19, 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