NexusFi: Find Your Edge


Home Menu

 





Object-oriented design for complex NinjaTrader strategies


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one cunparis with 2 posts (0 thanks)
    2. looks_two Big Mike with 1 posts (0 thanks)
    3. looks_3 zeller4 with 1 posts (0 thanks)
    4. looks_4 Boo Doo with 1 posts (0 thanks)
    1. trending_up 5,653 views
    2. thumb_up 0 thanks given
    3. group 6 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,972 since Jun 2009
Thanks Given: 534
Thanks Received: 3,720

Some of the strategies I develop are starting to get really complicated and long. I'd like to start modularizing my strats into separate class files, but NT doesn't seem to like that very much, every .cs has to either be a strat or an indicator. I also created a BaseStrategy class, which inherits from Ninja's strategy class, then tried to have my strats inherit from my BaseStrategy for my specific strategy sub-classes but Ninja didn't like that either. So how does one implement good OOP in Ninjatrader without creating one giant .cs file every time? The only alternative I can think of is to create an assembly (.DLL) in Visual Studio with helper methods and other re-usable functionality that my strats might want to use, like sending email, working with SQL Server, money management algorithms, etc, then reference it in Ninja and add a using statement to the DLL to bring in the outside behavior.

Any thoughts?


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
Ninjatrader users - good CONNECTIONs post and article fr …
NinjaTrader
Fabrication or Framework? Irans Denied MOU Explains the …
Prediction Markets & Event Contracts
Trump Lands in Beijing on CPI Day: Iran Peace Expires To …
Prediction Markets & Event Contracts
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
8 thanks
Darmok and Jalad at Tanagra
1 thanks
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,577

It's a good thought Scott.

I've not tried this, but you might try the .*.NinjaScript.Utility approach, you can place some code in the napespace within the .Utility (ie: shodson.NinjaScript.Utility.cs) and call them from multiple indicators or strategies.

Then just do an include reference:
 
Code
using shodson.Utility;
At the top of your code where you want to call it.

if I understand correctly, the NinjaScript.Utility is special in this way and for this purpose. I tried to find some documentation on it just now but couldn't, so I am only citing from prior examples of code I've seen that use this approach. (Roonius and VitaminC come to mind).

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
Boo Doo
Toronto
 
Posts: 1 since Oct 2009
Thanks Given: 6
Thanks Received: 0


You may find this useful:

NinjaTrader Support Forum > NinjaScript Development Support > General Programming > NT as a Black Box Development System

https://ninjatrader.com/support/forum/showthread.php?t=23275

particularly the post #6 by roonius with Visual Studio Solution sample attached:
https://ninjatrader.com/support/forum/showthread.php?p=130983


Reply With Quote
  #4 (permalink)
 
cunparis's Avatar
 cunparis 
Paris, France
 
Experience: Advanced
Platform: Market Delta & Ninjatrader
Trading: ES
Posts: 2,565 since Jun 2009
Thanks Given: 1,162
Thanks Received: 2,095


Boo Doo View Post
particularly the post #6 by roonius with Visual Studio Solution sample attached:
www.ninjatrader-support2.com/vb/showthread.php?p=130983#post130983

Thanks for the link to the project. I haven't used visual studio in a long time but I'm going to download it and try to make a simple indicator with it.

Anyone else doing this?


Follow me on X Reply With Quote
  #5 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 478 since Jun 2009
Thanks Given: 1,419
Thanks Received: 404

Hello cunparis,

Any progress with this new project?

Kirk


Reply With Quote
  #6 (permalink)
 
cunparis's Avatar
 cunparis 
Paris, France
 
Experience: Advanced
Platform: Market Delta & Ninjatrader
Trading: ES
Posts: 2,565 since Jun 2009
Thanks Given: 1,162
Thanks Received: 2,095


zeller4 View Post
Hello cunparis,

Any progress with this new project?

I got a copy of visual studio but haven't installed it yet. I plan to give it a try. What I want to do is put some of my algorithms into a DLL and then make an interface for Ninjatrader, Tradestation, & other platforms.


Follow me on X Reply With Quote




Last Updated on June 5, 2010


© 2026 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 - Downloads - Top
no new posts