Posts

NinjaTrader Logo
NinjaTrader stores all user configurations, indicators and strategies in this folder C:\Users\<user>\Documents\NinjaTrader 7\bin\Custom. NT does not allow to change the folder.
But it is possible to link a folder from somewhere else. E.g. you could store all your settings in your Dropbox folder and just link it to the NinjaTrader target folder.
 
Steps:
  • Run cmd. exe as Administrator
  • Execute mklink /D “C:\Users\<user>\Documents\NinjaTrader 7\bin\Custom” “C:\Users\<user>\Dropbox\Data\NinjaTrader\NinjaTrader 7\bin\Custom”
  • Use rmdir <link> to just remove the link
NinjaTrader Logo
NinjaTrader 7 uses a GridControl to let the user modify strategy or indicator properties. Properties marked with certain tags will be shown automatically in the Grid.
Example:
[Description("Numbers of bars used for calculations")]
[GridCategory("Parameters")]
public int Period {
    get {return iPeriod;} 
    set {iPeriod = Math.Max(1, value);}
}
It is possible to hide parameters in the GridControl dynamically. For supporting  this feature the strategy has to implement the interface ICustomTypeDescriptor. The property which allows to modify the visibility of other properties in the GridControl has to get additionally the tag RefreshProperties(RefreshProperties.All). Finally the function ModifyProperties implements the visibility handling.
public class tF_TestAnn : Strategy, ICustomTypeDescriptor
{
        [Description("ANN trade mode.")]
        [GridCategory("Parameters")]
        [RefreshProperties(RefreshProperties.All)]
        public  ENAnnMode AnnMode { get; set; }
 
        private void ModifyProperties(PropertyDescriptorCollection col)
        {
            if( AnnMode != ENAnnMode.Backtest )
            {
                col.Remove(col.Find("NetType", true));
            }
            if( AnnMode != ENAnnMode.Live )
            {
                col.Remove(col.Find("BuyLevel", true));
            }
        }

        public AttributeCollection GetAttributes()
        {
            return TypeDescriptor.GetAttributes(GetType());
        }

        public string GetClassName()
        {
            return TypeDescriptor.GetClassName(GetType());
        }

        public string GetComponentName()
        {
            return TypeDescriptor.GetComponentName(GetType());
        }

        public TypeConverter GetConverter()
        {
            return TypeDescriptor.GetConverter(GetType());
        }

        public EventDescriptor GetDefaultEvent()
        {
            return TypeDescriptor.GetDefaultEvent(GetType());
        }

        public PropertyDescriptor GetDefaultProperty()
        {
            return TypeDescriptor.GetDefaultProperty(GetType());
        }

        public object GetEditor(Type editorBaseType)
        {
            return TypeDescriptor.GetEditor(GetType(), editorBaseType);
        }

        public EventDescriptorCollection GetEvents(Attribute[] attributes)
        {
            return TypeDescriptor.GetEvents(GetType(), attributes);
        }

        public EventDescriptorCollection GetEvents()
        {
            return TypeDescriptor.GetEvents(GetType());
        }

        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection orig = TypeDescriptor.GetProperties(GetType(), attributes);
            PropertyDescriptor[] arr = new PropertyDescriptor[orig.Count];
            orig.CopyTo(arr, 0);
            PropertyDescriptorCollection col = new PropertyDescriptorCollection(arr);

            ModifyProperties(col);
            return col;

        }

        public PropertyDescriptorCollection GetProperties()
        {
            return TypeDescriptor.GetProperties(GetType());
        }

        public object GetPropertyOwner(PropertyDescriptor pd)
        {
            return this;
        }
}
NinjaTrader Logo

If you are planning to run your strategy within a chart window and your strategy requires an asynchronous execution or event, you can trigger this via dynamic buttons in the tool bar of the chart window.

In the code below the creation of the buttons and the event handler is implemented in a separate class. CStripButton is created in the OnStartUp context and disposed in the OnTermination context. A button click calls a callback implemented in the strategy class.

public class CStripButton
{
    private ToolStrip           toolStrip           = null;
    private ToolStripButton     toolStripBtnA       = null;
    private ToolStripButton     toolStripBtnB       = null;
    private ToolStripSeparator  toolStripSeparator  = null;

    private Strategy            clStrategy;
    private StripButtonCallback fnCallback;        

    public CStripButton( Strategy _clStrategy, StripButtonCallback _fnCallback )
    {
        clStrategy = _clStrategy;
        fnCallback = _fnCallback;
 
        System.Windows.Forms.Control[] control =
  _clStrategy.ChartControl.Controls.Find( "tsrTool", false );
 
        if( control.Length > 0 )
        {
            toolStrip = (ToolStrip)control[0];

            toolStripSeparator              = new ToolStripSeparator();
            toolStrip.Items.Add( toolStripSeparator );

            toolStripBtnA                = new ToolStripButton( "btnA" );
            toolStripBtnA.Text           = "Button A";
            toolStripBtnA.Click         += btnClick;
            toolStrip.Items.Add( toolStripBtnA );

            toolStripBtnB                = new ToolStripButton( "btnB" );
            toolStripBtnB.Text           = "Button B";
            toolStripBtnB.Click         += btnClick;
            toolStrip.Items.Add( toolStripBtnB );
        }
    }

    /// <summary>
    /// Destructor.
    /// </summary>
    public void Dispose()
    {
        if( toolStrip != null )
        {
            toolStrip.Items.Remove( toolStripSeparator );
            toolStrip.Items.Remove( toolStripBtnA );
            toolStrip.Items.Remove( toolStripBtnB );
        }
    }
 
    /// <summary>
    /// Button click handler.
    /// </summary>
    private void btnClick( object sender, EventArgs e )
    {            
        if( MessageBox.Show( 
             "Are you sure you want to continue?", 
             "Button pressed", 
             MessageBoxButtons.YesNo, 
             MessageBoxIcon.Question ) != DialogResult.Yes )
            return;

        var _bak = toolStripBtnTrain.BackColor;
        toolStripBtnTrain.BackColor = Color.Green;

        fnCallback( sender.ToString() );
 
        toolStripBtnTrain.BackColor = _bak;
    }
}

In the past I was typically developing strategies and indicators for automated Forex and Futures trading, using Ninjatrader, Tradingview and Metatrader. But since some time I get more and more requests for trading cryptocurrencies. There are clearly a lot of tools out there for Crypto-trading, however there are in my opinion very basic, typically using Python scripts and missing all nice features you got used to, like backtesting and optimization.

Therefore I want to focus here on options which do exists to my knowledge, automatically trading Cryptocurrencies while using a sophisticated trading environment/tool. With automatically trading I mean using a bot or tool which runs a strategy 24/7 unobserved.

The options listed below are just a quick overview, for detailed description of installation and usage please shoot us an email.

Ninjatrader 8

While NinjaTrader 8 is great in automation and scripting, it does not support trading cryptocurrencies out of the box. But there are now options out there which add Cryptocurrency support to NinjaTrader 8. Clearly the advantage of this solution is the rich and complete scripting (C# .NET language support), backtesting and optimization features of NinjaTrader.

NinjaTrader 8 is free for backtesting w/o any limitation, but must be leased or bought for trading live accounts, however for the Add-Ons listed below, this requirement does not exist.

Coinbase NinjaTrader Integration

The latest NinjaTrader 8 version supports Coinbase API natively. However, it only implements the market data API; it does not allow live-trading.

BitMEX NinjaTrader Integration

Link: see here

This integration allows access to the BitMEX market data, which allows leverages Cryptocurrency trading.

Unfortunately the API only integrates market data, but does not come with trading support. So it can be leveraged for backtesting e.g. XBTUSD in NinjaTrader 8, but for live-trading someone has to look for another solution.

Poloniex, Binance, Bitfinex, Deribit, BinancePlus Add-Ons

Link: see here

The Add-Ons are typically in the $150 to $250 area. If added to NinjaTrader they allow to access market data, but also enable trading of Cryptocurrencies.

I personally use the Binance adapter for some time, and didn’t find any bigger issues. One minor issue seems to be the fact that NinjaTrader’s internal performance handler can’t deal with split order executions, where one split has the size 0; this seems to happen only at certain Crypto-exchanges.

However, these Add-Ons don’t have the official NinjaTrader blessing, so you can’t expect any support from the NinjaTrader. 

Tradingview and Autoview Chrome extension

Tradingview is a great tool in regard to charting, quick implementation of ideas, it supports a zillion of Crypto-exchanges, but lacks automation. Latter is clearly a big minus. However, even if supported the question would remain how useful it would be running a strategy 24/7 in a Chrome browser environment.

That being said, there is a Chrome extension out there, called Autoview, which uses Tradingview Pine script alerts to trigger orders. Bit disadvantage of this solution is that there is no feedback about the trades, it’s basically submitting orders blindly into the dark 

The Chrome extension costs $5 per month, or $50 per year and can be found here: https://autoview.with.pink/. Tradingview is free, but also provides subscriptions, which do enable more features.

The built-in Pine script feature allows to add own strategies and indicators. But the features of Pine are clearly limited and can hardly be compared with the scripting capability of NinjaTrader for instance.

Please shoot us an email for any detailed question about the NinjaTrader and Tradingview features and support.

Portfolio Items