NinjaTrader Strategy Modification (recommended)

A small code modification is required to NinjaTrader strategy scripts to ensure that tsSignalCopier can identify a specific instance of your strategy to track. A new string property is added called "Stratid", and a new variable called "stratid" is added to save the property value. The new "Stratid" property is used by tsSignalCopier to scan all of the running strategies for a special id property to match with a value that you set in both your strategy and tsSignalCopier.

A sample strategy that includes the modifications can be downloaded using the link that follows this article below.

Explanation:

  • The NinjaTrader environment allows multiple instances of the same strategies and symbols to be running at the same time
  • tsSignalCopier needs to find and connect to a specific strategy instance to deliver orders to the intended broker or trade publisher
  • The internal id assigned by NinjaTrader changes each time the system is restarted, so it is not reliable as an identifier

 

There are two minor changes required:

Modification 1/2:

Look for the line #region Variables, and add the line shown in bold below:

#region Variables

         private string stratid = "myStrategyId";

Modification 2/2:

Look for the line #region Properties, and add the lines shown in bold below:

#region Properties

        [Description("Id for StrategyXtender")]
        [GridCategory("Parameters")]
        public String Stratid
        {
            get {return stratid;}
            set {stratid = value;}
        }

  • Compile your strategy and check for errors.
  • Adding the modified strategy to a chart, and set the "Stratid" value to a unique value, such as "Momentum Breakout Strategy 1". 
  • Add the tsSignalCopier strategy to your chart, and change the "TargetStrategyId" value to match the value assigned in your strategy.

Monitor the Output window to confirm that tsSignalCopier has located the correct strategy instance.

If everything is working correctly, you should see output similar to the following in the NinjaTrader Log Window:

*NT** Enabling NinjaScript strategy 'tsSignalCopier/2a98fd1786064ffa8a04d686710c2502' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=False MaxRestarts=4 in 5 minutes
2018/04/16 19:23:49 Collective2:97790500 tsSignalCopier 0.9.4 for NT7: Starting link to StrategyXtender...
2018/04/16 19:23:49 Collective2:97790500 SUCCESS SignalCopier Link Connected to localhost:51201
2018/04/16 19:23:49 Collective2:97790500 Searching strategies...
Checking tsSampleStrategy Id c31ef3a1a5614dbda1e7c1b85af42915
Found Strategy with Stratid=tsSampleStrategyX
2018/04/16 19:23:49 Collective2:97790500 FOUND Strategy with Private Target Id tsSampleStrategyX (Strategy:tsSampleStrategy Symbol:ES 06-18 DataSeries:500 Tick)
2018/04/16 19:23:51 Collective2:12345678 Strategy:tsSignalCopier Status Change: Loaded
2018/04/16 19:23:51 Collective2:12345678 Strategy:tsSignalCopier Status Change: Loaded

 

ZuluTrade Enabled Check to enable the Collective2 connector plugin
Login Enter your ZuluTrade login id (not an email address)
Password

Enter your ZuluTrade account password

Active Systems

not used

 

Max Positions

This specifies the maximum number of positions that can be open at one time for a single system.

Default: 4

Delay Between Orders

This specifies the minimum number of seconds to wait before a new order in the same direction for a symbol can be submitted to Collective2.

Default: 60

Max. Daily Trades

The maximum number of trades that can be opened per day, starting at 00:00 UTC.

Default: 8

API Key

Your Collective2 API Key (from your Collective2 settings under "My Account")

ADVANCED SETTINGS  
Server

Enter the server network address where the StrategyXtender Service is running. Normally, this "localhost" and does not need to be changed.

Default: localhost

 

Port

Enter the network port for the StrategyXtender Service:

Default: 51211

If you operate a private label version of Collective2, the latest build (6077) of StrategyXtender now supports "platform IDs", which are required to access and trade private label platforms via the C2 api.

Simply download and install the latest version of StrategyXtender, update your Collective2 settings with your PlatformID, and restart the StrategyXtender service. Your private label systems should now be visible in the StrategyXtender Dashboard.

StrategyXtender License Activation

A trial or permanent license key is required to activate StrategyXtender.

If you have registered for a trial or ordered a permanent key, a license key will be sent to you in an order confirmation email.

 

  • Start StrategyXtender
  • If this is the first time that the product has been started, you will be asked for a license key.
  • Otherwise, choose Help->License->Enter License

 

Copy the license key from the email, and click 'Paste Key from Clipboard'. The key should be displayed.

Click the 'Activate' button to start the software activation process.

If successful, you should see the following message:

If you don't see this message, please contact our support desk at This email address is being protected from spambots. You need JavaScript enabled to view it.

Click OK. The license details will be displayed:

 

 

Click the 'Continue' button to begin using StrategyXtender!

 

 

 

SignalCopier Chart Script

"SignalCopier" is a signal script included with StrategyXtender that follows market position changes generated by your own trading strategies. Its purpose is to connect your chart strategies to the StrategyXtender Windows Service, and enables you to publish trades in real time from your strategies to Collective2 or other services without any custom programming.

SignalCopier (_tsSignalCopier in MultiCharts and TradeStation) is attached to a chart like any other signal or strategy script. Setup parameters allow you to specify the symbol and quantity to be traded when entry and exit signals are detected from other signals attached to the same chart. All required communication with StrategyXtender and the connected trade publisher is performed in real time automatically on behalf of your other signal strategies.

_tsSignalCopier and support functions are installed as an archive file that must be imported and compiled before it can be used. The file containing _tsSignalCopier is installed in the default installation directory for your trading platform. Note that the file name shown will change depending on the software version:

  • MultiCharts64 (import and compile using PLEditor, "Read Only" import option)
    • 64 bit: c:\program files\TS Support\Multicharts64\StrategyXtender_API_V1.7.0S_MC64.sef
  • TradeStation 9.5 (import and compile using TradeStation Development Environment Editor)
    • c:\program files (x86)\TradeStation 9.5\Program\TRADERSCIENCE_STRATEGYXTENDER_API_V1.6.1X_PROTECTED.ELD

Once the archive has been successfully imported and compiled, add the signal named "_ts_tsSignalCopier" to a chart and update the settings to specify the target service and trading system, trade symbol, symbol type, and quantity. Here are some examples of how to set the _tsSignalCopier "ServiceId":

  SignalCopier ServiceId  
Collective2 "Collective2:12345678"  
Tradency "Tradency:12345"  
United Signals "UnitedSignals:mylogin"  
ZuluTrade "ZuluTrade:mylogin"  



When enabled, _tsSignalCopier will then connect to the StrategyXtender Windows service and establish a login session to the selected service, such as Collective2. When market position changes are detected resulting from your own signals attached to the same chart, _tsSignalCopier will create the necessary orders to open and close both long and short positions. _tsSignalCopier will regularly check the account position status and ensure that your strategy position and service account remain in sync.

_tsSignalCopier will respond to position changes normally on the next tick following the position change. Please note that this may result in some slippage between fill prices between your own strategy and C2.

Important: You can trade multiple strategies to a single account with your selected service, such as Collective2 or United Signals, but you must ensure that each strategy uses a unique trading symbol.

Shoud there be any interruptions in network availability, _tsSignalCopier will attempt to recover and resume normal operation automatically as required.


 

_tsSignalCopier Settings

Example Collective2 Settings in Signal Copier

 

Example United Signals Settings for Signal Copier

You must contact United Signals for your API Key.

 

Example ZuluTrade Settings for Signal Copier


 

ServiceID: This sets the target service and system or account for the target trade publisher or broker.

  • Collective2: "Collective2:nnnnnnnn", where n is your C2 SystemID
  • ZuluTrade: "ZuluTrade:myusername", where myusername is the ZuluTrade account username
  • Tradency: "Tradency:nnnnnn", where n is your Tradency system id
  • United Signals: "UnitedSignals:myusername" where myusername is your United Signals account login name

Note: quotation marks as shown are required!

Required Settings

ServiceEnable: true (enables service connection to StrategyXtender)

TradeSymbol: Symbol to be traded (must be in the format used by the target service)

Symbol Type: instrument or security type (choose "forex","future","stock", or "option")

GoLong: true - enable new long positions

GoShort: true - enable new short positions

OrderQty: Set the number of contracts, mini-lots, shares, or options to be traded when a new position is opened. (Default: 0, determined by strategy position)

QtyFactor: When OrderQty is set to 0, the order quantity is calculated by mulitplying the strategy quantity by this factor. For "forex", use .0001 to change the strategy quantity to mini-lots.

WaitUntilFlat:
true: don't close an existing position at the remote service if the strategy is flat
false: immediately synchronize the remote service position to match the strategy (warning: this may result in an position being closed!)

RecentBars: (default 3) _tsSignalCopier considers any signal generated by your strategy that is younger than the number of bars specfied here will be considered as an active signal to be sent to the remote service. This prevents stale signals that are active in your strategy when first starting _tsSignalCopier.

Optional Settings

ProfitTicks: If you wish to attach a profit target order, specify the number of ticks (pips) to be added to the entry price for Long positions, (subtracted for Short positions).

StopLossTicks:
If you wish to attach a fixed stop loss order, specify the number of ticks (pips) to be subtracted from the entry price for Long positions (added for Short positions)

MinOrderMoveTicks: Price must change by at least this many ticks before moving an existing stop loss or profit target order

MinBuyPower: Minimum buying power required to open a new position (Collective2 only)

Comments:   Additional notes to be included with signals for this strategy. (Collective2 only)

TimeInForce: Specifies the valid duration for new orders:
"GTC": Good Till Cancel (order remains active until filled, cancelled by user, or expired by broker)
"DAY": order valid until end of current session (default)

StrategyID: (default: 0) for order tracking by stragegy  (future version)

 

 

 

ZuluTrade Configuration

In your ZuluTrade account, be sure to enable API access in your settings, as in the following snapshot:

 

StrategtyXtender Settings for ZuluTrade

Login:

    enter your ZuluTrade account name (not your email address)

Password:

    enter your ZuluTrade password (it is encrypted when saved on your system)

Active Systems:

     enter "*" (asterisk) character to enable all of your ZuluTrade accounts to appear

TraderScience is a registered trademark of TraderScience Corporation.

StrategyXtender is a trademark of TraderScience Corporation.

TradeStation®, EasyLanguage® and PowerEditor® are registered trademarks of
TradeStation Technologies, Inc.

MultiCharts® is a registered trademark of Multicharts LLC.

eSignal® is a registered trademark of Interactive Data Corporation.

Any trademarks used on this website and not specifically listed here are the property of their respective owners.

TraderScience Corporation Liability Disclaimer

TraderScience Corporation ("TraderScience"), or any of its representatives, is neither a registered Investment Advisor nor a Broker/Dealer. Clients and readers are advised that all information is issued solely for informational purposes and is not to be construed as an offer to sell or the solicitation of an offer to buy, nor is it to be construed as a recommendation to buy, hold or sell (short or otherwise) any investment security. All opinions, analyses and information included herein are based on sources believed to be reliable and written in good faith, but no representation or warranty of any kind, expressed or implied, is made including but not limited to any representation or warranty concerning accuracy, completeness, correctness, timeliness or appropriateness.

The products and services offered on this website and their performance may be based on historical and/or hypothetical performance results. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. Hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk in actual trading. There are numerous other factors related to the markets in general or to the implementation of any specific trading program which cannot be fully accounted for in the preparation of hypothetical performance results and all of which can adversely affect actual trading results.

Trading financial instruments, including futures, options and foreign exchange carries a high level of risk and is not suitable for all investors. A high degree of leverage can work against you as well as for you, and you may lose some or all of your initial investment. Carefully consider your investment objectives, level of skill, experience and risk appetite before deciding to trade or invest in financial securities and ensure that you do not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor before trading with your own capital.

Limitation on Liability. THE AGGREGATE LIABILITY OF TRADERSCIENCE ARISING FROM OR RELATING TO THIS AGREEMENT, INCLUDING USE OF TRADERSCIENCE PRODUCTS AND SERVICES, PUBLISHED CONTENT OR DOCUMENTATION (REGARDLESS OF THE FORM OF ACTION OR CLAIM –  E.G., CONTRACT, WARRANTY, TORT, STRICT LIABILITY, MALPRACTICE, AND/OR OTHERWISE) SHALL NOT EXCEED THE TOTAL PAYMENT MADE BY CLIENT FOR PRODUCTS AND SERVICES OF TRADERSCIENCE. TRADERSCIENCE SHALL NOT IN ANY CASE BE LIABLE FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT, OR PUNITIVE DAMAGES, OR FOR LOSS OF PROFIT, CAPITAL, REVENUE, DATA, OR PROGRAMS, EVEN IF TRADERSCIENCE HAS BEEN ADVISED OF THE POSSIBILITY THEREOF.  THIS SECTION APPLIES TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW. Because some states/jurisdictions do not allow the exclusion or limitation of liability, the above limitation might not apply, and Licensee may have other rights that vary from state/jurisdiction to state/jurisdiction.

Government Required Risk Disclaimer and Disclosure Statement

OUR PRODUCTS AND SERVICES ARE BASED, AMONG OTHER THINGS, ON SIMULATED OR HYPOTHETICAL PERFORMANCE RESULTS. THESE RESULTS ARE BASED ON SIMULATED OR HYPOTHETICAL PERFORMANCE RESULTS THAT HAVE CERTAIN INHERENT LIMITATIONS. UNLIKE THE RESULTS SHOWN IN AN ACTUAL PERFORMANCE RECORD, THESE RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, BECAUSE THESE TRADES HAVE NOT ACTUALLY BEEN EXECUTED, THESE RESULTS MAY HAVE UNDER-OR OVER-COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED OR HYPOTHETICAL TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFITS OR LOSSES SIMILAR TO THESE BEING SHOWN

TradeStation Disclaimer

Neither TradeStation Technologies nor any of its affiliates has reviewed, certified, endorsed, approved, disapproved or recommended, and neither does or will review, certify, endorse, approve, disapprove or recommend, any trading software tool that is designed to be compatible with the TradeStation Open Platform.

 

Account Setup - Collective2 Settings

  •  Clck on the + sign to add a new account.
  • A new account record is created.
  • The Brokerage Type is set to "Collective2" by default.
  • To change the Brokerage Type, use op drown list to the right, choose the Brokerage Type,in this case we'll use the default value, "Collective2"

account settings3a c2

 

Once you have selected the Brokerage Type, the required settings will be updated in the display:

account settings4a c2

 

Collective2 Settings Explained

 

Account Name A descriptive name to help you remember this accout, eg. "Collective2 Test Account"
AccountId Collective2 "SystemId", eg, 87651234
AccountType: Choose "Margin"
API Key Your Collective2 API Key (from your Collective2 settings under "My Account")
Login Enter your Collective2 login email address
Data Password

Enter your Collective2 Data Services Password
(note: this is not the main C2 login password)

Required Collective2 Account Management Settings:

  • Login to the Collective2 website
  • Navigate to Account Management
  • Select the Data Services tab

Enter your Data Services Password.

Ensure the following options are checked:

Enable Data Services

Enable Trade Entry

Click the Submit button.

UniqueId Automatically assigned. This number will be used by the SignalCopier script settings to connect a specific account with your trading strategies.
 

 

 

 

   

 

Connect to Collective2

When your settings have been updated, click on "File", then "Save Settings".

Right click on the Account, and choose "Connect". In a few moments, the account details should be updated with your current Collective2 System details.

account settings5 connect