NexusFi: Find Your Edge


Home Menu

 





Common code re-use


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one LostTrader with 4 posts (0 thanks)
    2. looks_two fluxsmith with 2 posts (0 thanks)
    3. looks_3 MXASJ with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 7,334 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 12 posts
    2. attach_file 0 attachments




 
Search this Thread

Common code re-use

  #11 (permalink)
 
pengi's Avatar
 pengi 
Tokyo, Japan
 
Experience: Intermediate
Platform: NT7
Trading: GC
Posts: 35 since Jan 2011
Thanks Given: 26
Thanks Received: 40


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:

 
Code
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.

 
Code
public class PengiES : PengiBase

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 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
  #12 (permalink)
 dmh24 
Denver, CO
 
Experience: Advanced
Platform: SierraChart
Broker: Optimus, Rithmic
Trading: ES
Posts: 67 since Sep 2011
Thanks Given: 6
Thanks Received: 34

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
  #13 (permalink)
 Xeno 
UK
 
Experience: Intermediate
Platform: Ninja
Broker: Mirus/Zen
Trading: Futures - bonds, currencies, index
Posts: 288 since Oct 2010
Thanks Given: 70
Thanks Received: 274


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
Thanked by:




Last Updated on October 5, 2011


© 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