Common code re-use (Page 2) - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

Common code re-use
Started:July 28th, 2010 (05:22 PM) by LostTrader Views / Replies:2,976 / 12
Last Reply:October 5th, 2011 (05:50 PM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Common code re-use

Old October 5th, 2011, 04:44 PM   #11 (permalink)
trading my rent money
Tokyo, Japan
Futures Experience: Intermediate
Platform: NT7
Favorite Futures: GC
pengi's Avatar
Posts: 35 since Jan 2011
Thanks: 26 given, 39 received

LostTrader View Post
If anyone has examples of C# common code re-use that they would liketo share, or more techniques that can be implemented in a NinjaScript cs file, please chime in!

Just put all your generic strategy code in a class derived from the strategy class:

public class PengiBase : Strategy
Then make individual strategies that inherit from this new base class. Since your base class inherits from the Strategy class, they are also Strategy objects and can call all the Strategy methods like Print() etc.

public class PengiES : PengiBase

Reply With Quote

Old October 5th, 2011, 05:41 PM   #12 (permalink)
Elite Member
Denver, CO
Futures Experience: Advanced
Platform: SierraChart
Broker/Data: Optimus, Rithmic
Favorite Futures: ES
Posts: 67 since Sep 2011
Thanks: 6 given, 31 received

If you have methods that are small and multi-purpose, you can put them in the UserDefinedMethods indicator/strategy and have access to them in each respective namespace without having a bunch of other files with static classes everywhere.

Reply With Quote

Old October 5th, 2011, 05:50 PM   #13 (permalink)
Elite Member
Futures Experience: Intermediate
Platform: Ninja
Broker/Data: Mirus/Zen
Favorite Futures: Futures - bonds, currencies, index
Posts: 288 since Oct 2010
Thanks: 70 given, 248 received

I have a mixture of utility procs in the user defined methods (I created my own - udm) and just used the namespace strategy and partial class strategy. I also have a load of extra classes that do bigger jobs, and I do indeed pass in the strategy to each one so I can use all the strategy methods.

Reply With Quote
The following user says Thank You to Xeno for this post:

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > Common code re-use

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Protecting code sam028 NinjaTrader Programming 30 April 21st, 2016 12:01 PM
Help with paintbar code. bfreefalling NinjaTrader Programming 2 April 28th, 2011 09:54 AM
Can someone code this ? skyfly NinjaTrader Programming 8 April 25th, 2011 12:40 PM
Obama’s Twist of BP’s Arm Stirs Common Tactic Debate Quick Summary News and Current Events 2 June 18th, 2010 09:39 AM
Having some issues with this code. Please help. kaywai NinjaTrader Programming 3 March 4th, 2010 10:33 AM

All times are GMT -4. The time now is 01:09 AM.

Copyright © 2016 by 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

Page generated 2016-10-27 in 0.07 seconds with 19 queries on phoenix via your IP