Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 - NS Wrappers alternative and side by side dlls

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

    NT8 - NS Wrappers alternative and side by side dlls

    This is low priority.... i think this could be a useful consideration if my hunch is right about NSWrappers and the old NT7 style... i might be way off but without the NT codebase to play with i am guessing a bit.... :-) I am summising side by side assemblies will help

    I am looking at certain old features /limitation in NT7 that hinge around strategies that are derived from a base class which was derived and exported from NT7......

    1. visibility of the indicatorbase NSWrappers to derived classes....
    2. Exceptions - how you have to workaround the methods such as ADD(indicator) and when it causes an issue... and exception.... due to the scope and context of which NSWrapper method is used....
    3.Is it possible to negate the need for the loose cs file to be deployed with compiled dlls?

    Question:
    Why is it not possible for an assembly to use the methods nt generates into the indicator? why is the loose file required to ship with a compiled dll?

    Because these are compiled into the scope of the indicator and strategybase namespaces at compile time....

    But why do that?
    Main Question:

    Consider if NT compiled down the custom strategies to a seperate DLLS for each major feature object class etc and
    NinjaTrader8.Custom.Strategys.dll
    NinjaTrader8.Custom.Indicators.dll
    NinjaTrader8.Custom.BarTypes.dll

    and NinjaTrader8.Custom.Indicators.dll contained all indicators as compiled -with code generated only for the indicator scope/namespace. and did not do it for strategy - or market analyzer.....

    Maybe none of the above is an issue in NT8... except the visibility of NSWrappers methods
    ultimately the problem is this in NT7 - Exceptions and work arounds - so im trying to think if i can suggest something for NT8....

    i can see the code is hard to change in the object model.... so you can use the syntax EMA(10) from anywhere
    public partial class Indicator : IndicatorBase
    public partial class Column : ColumnBase -
    public partial class Strategy : StrategyBase

    all have the NSWrappers in two places
    1.open source indicators
    2. with compiled indicator dlls

    it seems to me that it should be possible someother way.....


    no params
    Code:
    #region NinjaScript generated code. Neither change nor remove.
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
        public partial class Indicator : IndicatorBase
        {
           public static EMA EMA()
            {
                return EMA(Input);
            }
    .....
      }
    }
    #endregion etc



    Static?
    Code:
    #region NinjaScript generated code. Neither change nor remove.
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
        public partial class Indicator : IndicatorBase
        {
           public static EMA EMA(int period)
            {
                return EMA(Input, period);
            }
      }
    }
    #endregion etc
    Overrides for
    Virtuals which are overridden in the loose cs file?? to negate need to code it all again?

    Code:
    #region NinjaScript generated code. Neither change nor remove.
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
        public partial class Indicator : IndicatorBase
        {
           public virtaul EMA EMA(int period)
            {
                return EMA(Input, period);
            }
      }
    }
    #endregion etc
    Maybe you will always needs the NSWrappers for all other objects....

    for compiled deployments
    1. but what about the loose nswrappers - what if you remove this- why can't we view the internal indicatorbase methods exposed by the dll if the dlls are referenced....
    2. why do compiled base class and derived classes have an Exception when using the Add() method on init....

    Anyway here is the pattern to get around it in NT7


    Scenario
    A deployed referenced Strategy compiled foundation class
    Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


    A series of open source files that reference it:



    the problem is:

    Code:
    public abstract class AwesomeStrategyBase : Strategy
    {
    protected override void Initialize()
    {
    Add(indicatorX(10));
    }
    }
    complied assembly AwesomeStrategyBase.dll imported into NT7

    Code:
    public class Strategy1Y: AwesomeStrategyBase
    {
    protected override void Initialize()
    {
    
    base.Initialize();
    // Problem 1 Exception  caused in base class on Add(indicatorX(10)
    
    ///Problem 2 Compiler Error IndicatorY(Period in) not reachable
    Add(indicatorY(10));
    
    }
    }
    Solutions :
    #1 compiled dll
    Code:
    public abstract class AwesomeStrategyBase2 : Strategy
    {
    protected override void Initialize()
    {
     BaseClassIndicatorsSetupAndAdd();
    }
    
    public virtual void BaseClassIndicatorsSetupAndAdd()
    {
      Add(IndicatorX(10));
    }
    
    }
    complied assembly AwesomeStrategyBase2.dll imported into NT7


    #2 //Open Source file deployed to NT Strategy folder

    Code:
    public abstract partial class AmazingStrategy : AwesomeStrategyBase2 
    {
    	protected NinjaTrader.Indicator.ADX _proxyIndicator = new NinjaTrader.Indicator.ADX();
            public MTDoubleShotStrategy()
    	{
    	  _proxyIndicator .Input	= Input;
    	 _proxyIndicator .Strategy	= this;
    	}
    
            public override void BaseClassIndicatorsSetupAndAdd()
            {
               Add(_proxyIndicator.IndicatorX(10));
    //required to  use the NSWRappers context compiled into the local open source strategybase and indicatorbase  - prevents errors on adding to a chart.... if called in base compiled file.... cross threading or something?
            }
    
    other methods same as strategybase
    ..... ETC
    
    }
    #3 Open Source file in Strategy Folder
    Code:
    public class AmazingStrategyCrossover : AmazingStrategy 
    {
    
    private EMA fastMA = new EMA();
    
    protected override void Initialize()
    {
      base.Initialize(); 
     //indicators NSWrappers not visible at this level use  _indicator.
     fastMA = _proxyIndicator .EMA(this.FastMAPeriod);
     Add(fastMA);
    }
    
    
    		[GridCategory(" Indicator Parameters")]
    		public int FastMAPeriod
    		{
    			get { return fastMA.Period; }
    			set { fastMA.Period= value; }
    		}
    
    }

    #4 Open Source file in Strategy Folder with a copy of the NSWrappers method - MORE WORK
    Code:
    public class AmazingStrategyCrossover : AmazingStrategy 
    {
    
    private EMA fastMA = new EMA();
    
    protected override void Initialize()
    {
      base.Initialize(); 
     //indicators NSWrappers not visible at this level use  the method defined at this level
     fastMA = EMA(this.FastMAPeriod);
     Add(fastMA);
    }
    
    
    		[GridCategory(" Indicator Parameters")]
    		public int FastMAPeriod
    		{
    			get { return fastMA.Period; }
    			set { fastMA.Period= value; }
    		}
    
      public Indicator.EMA EMA(int period){}
      public Indicator.EMA EMA(Data.IDataSeries input, int period)
     {
     return _proxyIndicator .EMA(this.FastMAPeriod);
     }
    
    }
    Last edited by MicroTrends; 05-10-2015, 05:17 AM.
    MicroTrends
    NinjaTrader Ecosystem Vendor - micro-trends.co.uk

    #2
    This subject is covered already in thread


    It would be great if you could post your suggestions there.

    Comment


      #3
      ok i wanted to split it out as i hijacked the thread
      MicroTrends
      NinjaTrader Ecosystem Vendor - micro-trends.co.uk

      Comment


        #4
        Understand. I felt it made sense to continue where we started so no information is lost/split up.

        However, you are right: on new subjects it would be great if you could split them out to separate threads right from the start.

        Comment


          #5
          To see the patterns that get around the limitations in NT7 see Post #1
          for the compiled baseclass and derived classes.... and indicator ns wrappers visibility etc
          MicroTrends
          NinjaTrader Ecosystem Vendor - micro-trends.co.uk

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rocketman7, Today, 09:41 AM
          3 responses
          7 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by traderqz, Today, 09:44 AM
          2 responses
          4 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by stafe, 04-15-2024, 08:34 PM
          8 responses
          40 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by rocketman7, Today, 02:12 AM
          7 responses
          31 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by guillembm, Yesterday, 11:25 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X