The NinjaScript add-ons you’ll find here in the free section are must-have utilities. I’ve found these C# snippets invaluable when developing an automated/algorithmic trading strategy. Whether you’re coding for HFT, day trading, swing trading or long term holding, there are certain mechanics that are absolutely necessary. When applicable, these .cs files have been written to be easily dialed in via a “dashboard” — a set of user-controlled variables you’ll find near the top of the .cs file in a region named “dashboard.”
Check back often. I’m always working to add new free code.
- Set a market stop and limit target when entry order is filled
This free NinjaScript will set a resting stop loss market exit and a limit profit target exit at the time your entry order is filled.
- AI Shadow Probe (Free Machine Learning Strategy)
This free NinjaScript strategy will place simulated trades behind the scenes to feel out the current market conditions. When your defined tracking time starts each day, the Shadow Probe will enter and track hundreds of simulated positions with every stop/target combination in a range you define (e.g. if you set the range to 2-100, the Shadow Probe will run simulated trades with a stop/target of 2/2, 2/3, 2/4...... all the way to 100/99, 100/100. With this Shadow Probe data you will know the most profitable S/T combination for the day and an infinite number of other ways you can think of to implement the probe data.
- Daily profit/loss limit
This free NinjaScript strategy will close any open positions and stop trading for the current day if your daily P/L reaches a set negative or positive value. If you have a strategy that you run uninterrupted over multiple days, this indicator will reset the daily P/L back to zero at the beginning of each day for a fresh start. In addition to limiting trading based on P/L, you can limit the daily timeframe in which you'd like to trade, i.e. trade only from 9am to 11am.
- Exit at breakeven if first tick goes against you
This free NinjaScript strategy will place a limit exit order at break even if the first tick after your order is filled is in the adverse/wrong direction.
- Add a secondary time/data series
This free NinjaScript will add a secondary data series to your strategy.
- Track the last 10 bid/ask price level changes
This free NinjaScript will store the last 10 changes in the bid/ask price in a list. You can use this in many ways, e.g. exit position if the first one or two level changes move against you. This is more granular and can tell you more than tracking the last 10 changes in the last traded price.
- Enter in random direction
This free NinjaScript will randomly determine whether to enter long or short.