Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Adding / calling multiple classes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Adding / calling multiple classes

    Hi,

    I am integrating a 3rd party position size / order management tool into my strategies. The strategy uses the 3rd party's base class (where 'GWSEasyA' is the name of my strategy).

    public class GWSEasyA : MTStrategyBase


    I need to add in indicators from the Ninjatrader class and I'm stumped - any ideas where to start?


    Thanks in advance

    #2
    mokodo, so the 3rd party calcs come from a DLL here? Then you could add this as a reference to the NinjaScript editor via a right click in the code > References.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      so the 3rd party calcs come from a DLL here?

      Not sure what you mean with this,

      But the .dll from the 3rd party is already in the references

      Comment


        #4
        If you have it already referenced then just add a using directive and you should be able to call it's methods.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand,

          Here's a link to the approach I'm taking



          And here's the top end of the code:

          #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
          {
          [Description("Gold Break Out working sheet")]
          publicclass GWSEasyA : MTStrategyBase
          {
          #region Variables


          #endregion


          protectedoverridevoid Initialize()
          {

          Now when I try to Initialize an indicator (which is not listed via 'this.' within MTStrategyBase) I get the following error on compiling:

          'NinjaTrader.Indicator.TradingEnviroment30' is a 'type' but is used like a 'variable'

          Comment


            #6
            Sorry we would not be really familiar with this 3rd party approach here - please note the additional references their file would install, that are likely needed for the framework shown to function as expected.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              OK thanks for the feedback. I think my general question is how to call on two classes in one strategy - perhaps you can help me with that

              Comment


                #8
                Sorry, I don't follow you - if you using the NinjaTrader namespace in your strategy (which be default you do) you would have access to the indicator classes contained as well. You can certainly adding more using directives to make custom namespaces or other .NET ones available for working with it.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  @mokodo

                  did you get that resolved? I'm having same issue.

                  Comment


                    #10
                    alexxx76
                    No I didn't I'm afraid. As it transpired I did not get on with the 3rd party add-on anyway and coded in the features I wanted myself.

                    Comment


                      #11
                      The Problem is that the MTStrategyBase, inherits from the NinjaTrader.Strategy.Strategy class and is compiled and can only see indicators it was compiled with that were within NT7 at the time of compiling. Its an architectural restriction in NT7 and has no easy solution other than the awesome NT dev team fixing it their end...:-)

                      We will have to rewrite the CodeBase to offer a solution, with template files that allow access to your local indicators and allow the NSWrappers Strategy. factory methods that create the indicators to be visible and also if accessed in the initialise add method do not cause erros due to threading or something.

                      If you dont need to backtest - you can attach a strategy that used the MTStrategyBase to it and trade it. see this pattern of binding to types that already instantiated and running.. bind using interfaces to indicators on charts by name..




                      There is a new project underway that allows you to get around this issue, using a compiled strategybase and also then a loose .cs file similar to @strategy - which when compiled will pick up your local indicators too. But this pattern cannot be used wiht MTStrategyBase due to issues NT has when creating the indicators from the other assembly with the strategy context...

                      You can send in for code snippet help at the MicroTrends HelpDesk.
                      Last edited by MicroTrends; 03-01-2012, 11:42 AM.
                      MicroTrends
                      NinjaTrader Ecosystem Vendor - micro-trends.co.uk

                      Comment


                        #12
                        i might even release it as open source, for a fee or free - how could one control its distribution?
                        At least that way there would be no issues as your indicators get compiled in with it all and work a treat... I would then also release a compiled locked down version for non programmers, The open source version might contain all strategies and indicators only the core...
                        if you are interested in that let me know.
                        MicroTrends
                        NinjaTrader Ecosystem Vendor - micro-trends.co.uk

                        Comment


                          #13
                          MTDoubleShotStrategyBaseFoundation and Demo Crossover

                          In fact i have decided to show you how its done:
                          MTDoubleShotStrategyFoundation.Zip is a compiled (beta) unmanaged strategy base class containing some generic methods and properties, and NinjaBuddy GUI for interacting with your strategy.. MTDoubleShotStrategyFoundation.Zip
                          has some fairly cool features... send your feeback to [email protected]

                          Import this first...

                          I have attached a moving average crossover strategy built from it witin a few minutes,
                          that allows single, double, triple rising, falling permutations, using an EMA, SMA and WMA - you can mix it all up using bitwise rules for trade entry and even add in filters and exit rules...etc whats more it allows you to get around the architectural limitation as described below - thanks to Andreas Zweistein Trading who works with MicroTrends Dev Team as a Senior Lead Developer and showed me this... i almost had it but not quite, one protected keyword away...
                          MTDoubleShotStrategyCrossoverDemo.Zip
                          contains the 2 files you need for this work around.
                          Import 2nd then look in edit strategies... and compile...

                          You can use the same pattern to build a stratgey using the trade management features provided etc..
                          Attached Files
                          Last edited by MicroTrends; 03-01-2012, 11:18 AM.
                          MicroTrends
                          NinjaTrader Ecosystem Vendor - micro-trends.co.uk

                          Comment


                            #14
                            Upon import where do the .dll's get stored?

                            Comment


                              #15
                              Originally posted by Hawk Arps View Post
                              Upon import where do the .dll's get stored?
                              They should be found then in your Documents\NinjaTrader 7\bin\Custom folder.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by tradingnasdaqprueba, Today, 03:42 AM
                              6 responses
                              29 views
                              0 likes
                              Last Post tradingnasdaqprueba  
                              Started by kaywai, Today, 11:59 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by ETFVoyageur, 04-30-2024, 02:04 PM
                              13 responses
                              110 views
                              0 likes
                              Last Post ETFVoyageur  
                              Started by Skifree, Today, 11:21 AM
                              1 response
                              2 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
                              52 responses
                              5,265 views
                              0 likes
                              Last Post olivierh  
                              Working...
                              X