s
Contact Login Register
h M

NinjaTrader Algo Trading Strategies

rss

Best practices for NinjaTrader Algotrading with indicators and strategies.... Topics include algograding with Futures, Crypto, Forex, and equities/stocks. How do you backtest / optimize strategies with NinjaTrader? You have come to the right place!

Strategy Analyzer - Analyzer 13 & Inbox - Nash Technologies LLC _- Mail 2021-04-12 at 8.15.43 PM.jpeg

NinjaTrader strategy analyzer has many features that you don't always know until after you have worked within the interface for a while...


Seven quick tips for working with NinjaTrader Strategy Analyzer... 

Epic Tip 1: Whenever you optimize an algo strategy, you can expand the minimum / maximum properties and type in each field, or simply type directly in the textbox. 

It can take some work to go step by step through a strategies properties and setup the minimum and maximum values for optimization... but did you know you can also just type in the textbox within strategy analyzer?

Option 1: Expand the properties settings and manually enter values for minimum, maximum, and the value to increment. 

Option 2: Simply type in the values without expanding. The format is min;max;increment. So to increment values from 50 to 200 in increments of 25 it would look like: 50;200;25

Epic Tip 2: Tick Replay? Maybe not needed with high-fill resolution!

Certain algo strategies (including most Epic Collection strategies!) are coded to take advantage of tick replay, and the strategy results can greatly benefit by enabling this feature. Within NinjaTrader, you can enable the feature under Tools, Options, Market Data, Show Tick Replay. 

This option will then be available within the data series when you are setting up strategies or strategy analyzer.  To learn more about how tick replay works and the advantages for enabling the feature you can check out the NinjaTrader user guide. https://ninjatrader.com/support/helpGuides/nt8/?tick_replay.htm

Why not always enable tick replay? There is a significant performance impact! Want a better option without the need to have the major performance hit? You can specify the order fill resolution to be set to "High" and choose a value such as every minute or even every second. You might be surprised with how the results are similar to tick replay without the major performance hit. 

Epic Tip 3: Strategy Analyzer Logs.

By default, you might not even know strategy analyzer had logs... and perhaps that's because they shouldn't even be called logs. When I first heard of the strategy analyzer logs I assumed they were referring to log files I might need to send their support team, or perhaps log files that might include errors the strategies have or a reference that I had to open up in notepad etc...  

Well... get ready for a surprise! With all of the work and time that goes into strategy optimization, its a shame when the results just get lost if you don't export or save the results within a template.  This is where strategy logs can be helpful. 

To enable the logs, you right click within the strategy analyzer interface. You will see an option to "show logs". 

Wow! Look mom... I can filter by strategy or by instrument!

Oh... I can also right click within the grid, and open these past historical results within strategy analyzer!

From here you can research all of your past strategies and optimization results... You can "pin" them, and enable features within the "properties" section of Strategy Analyzer to show columns such as the profit factor, or button to view and open the strategy. 

Epic Tip 4: Save templates to move between workstations.

When moving between development and production environments, it can be extremely helpful to save templates. Saving templates within strategy analyzer is easy...  in the bottom right you will see a "Templates" menu item, where you can click it to open, or save templates. These can then be retrieved when you want to go and enable a strategy within the strategies tab of NinjaTrader, or within the strategies interface within NinjaTrader charts. 

So how do you move them from one work station to another? Easy... simply zip up/compress the folders under your templates folder, copy them to the other system, and unzip them.  Typically this directory is here: \Documents\NinjaTrader 8\templates\Strategy folder. 

We provide a full video that covers this process, including how to take advantage of optimized templates we provide for the best NinjaTrader strategies. 

You can check out the video and download templates at http://www.nashtech.xyz/templates.

Epic Tip 5: Sort by your worst trades... Add other indicators to the chart to see if you could have avoided that entry. 

Often times a strategy has great results and trades great except a couple bad apples that really impact the overall results. You can easily find the worst trades, navigate within the chart for those times and sometimes get a better picture for what might be happening. 

For example, many custom strategies we build for clients we often include an overall "max stop loss". This is needed for example if their normal stop loss is set to "last bar high/low", when the previous bar was so parabolic and significant that it really impacted their stop loss. 

First, navigate within Strategy Analyzer by clicking in the upper left dropdownlist, and select "Trades". Next, check out the entry time and exit time within the executions. 

Next, navigate within the "Chart" by selecting that from the dropdownlist. Navigate to that date/time of the entry and see if you can determine anything that would have helped keep you out of that trade? Sometimes this includes adding other indicators on the chart and checking their values. Most of the epic collection of strategies include features to "Opt Out" of trades if the Vortex indicator, choppiness indicator, or ADX indicator are at extreme ranges. 

Oh... and if you are trading with the best NinjaTrader strategies and you find your results are just horrible? Just choose the option for trade direction and change it to "reverse" :) All the strategies within the Epic Collection include the ability to trade in reverse if the setup is optimized so poorly you want to actually trade differently. 

Epic Tip 6: Backtest against multiple instruments at once, use percent and variables such as ticks rather then fixed currency.

If you discover that similar settings for your strategy work across many instruments, consider testing against many instruments at one time. How do you do this? Well first, hopefully your settings are using input variables such as percentages, ticks, pips, etc... When you have fixed currency type variables its harder to backtest against multiple instruments. Next... When you have selected to backtest or optimize within strategy analyzer, choose the instrument and instead of selecting the single instrument, choose "Select All". This is helpful also if you want to enable the strategy on live simulator accounts as it can create the strategy for each instrument rather you manually selecting each and every instrument. The results will spit out per instrument and save you a lot of time! 

Epic Tip 7: Take optimization sloooooowly.

Strategy optimization is powerful... but take when not used properly, it can be a waste of time. For example... what if you forget to select to trade both long and short, and you don't realize this until the optimization takes hours to run? Or after you feel comfortable with the strategy you want to test all different variables and multiple profit targets and stop losses, only to realize when you click run its going to take 70 days to complete! This can easily happen when you define too many variables, too small of increments, etc... Try adjusting the minimum and maximum on just a couple variables to make sure you don't end up with an optimization that takes days to complete! 

Epic+Bounce%2C+setup+for+large+wicks+near+high+lows.+Configured+entry+two+bars+after+signal+confirmation..jpeg

Trading crypto futures with NinjaTrader and Epic Bounce strategy. 

c398deea-4f71-4a93-a970-d8a5f9f80124.png

Several customers have been wanting to trade TD Ameritrade / thinkorswim with algo trading and after they initially research this idea... they usually end up in an endless loop trying to backtest using TDA OnDemand (extremely limited), and then they also find out that although Thinkscript is easy to learn and similar to C#, there is no real way to actually enable (at least at this time and likely a while given the Charles Swab merger).

So... For these clients some of the suggestions we have been utilizing several setups for Algo Trading with Epic Collection. I do want to point out several pros and cons when algo trading with TD Ameritrade and NinjaTrader:

Cons (as far as I know, most of these are all known issues when searching the NinjaTrader forums):

1. TD Ameritrade doesn't provide tick data and doesn't seem to work well with intrabar setups where the stop loss might change over time. 

2. Lots of errors pop up (which seems difficult or I can't find a way to disable) for things such as "no shares to short" messages. We ended up setting up only long setups. 

3. When an OCO orders is placed with a profit target and stop loss... that cannot be changed throughout the duration of the order. So basically for any setups where you would ever want to change the stop loss or profit target, this is a problem. 

4.  We initially had problems when we would have hundred plus positions open with the NinjaTrader feature "Close all positions" at a specific time. Basically this would work great with 15 instruments but with 100 it would end up timing out and leaving positions open overnight! 

We later added code into Epic Collection to set the trading session hours outside of the instrument trading hours. This is helpful for many reasons as there is also the option to flatten the strategy and end it if its running outside of that timeframe.

Pros:

1. No commissions! 

2. Sometimes the trades for Epic VWAP or Epic Bid would be in/out over 250+ times per day for over 100+ instruments! Seemed to trade well, especially for setups where the setting was "OnBarClose" and at least a 5 minute or more data series. 

3. Easily setup similar strategy that would run on percent basis with "Dynamic Quantity" enabled on the Epic Bid or Epic Follow strategy... With this we would run a daily import for specific stocks we wanted to target for the day, import this into a list within NinjaTrader, and then choosing the instrument for the strategy, choose "Select All" for the instrument list. This would end up creating 100+ strategies all with the similar parameters and all we have to do each morning is import the list, create the strategy one time and then right click on all of them and click "Enable".

PYPL trades well with Epic Follow... Epic Follow will look for correlation between index's or another instrument and if a major change in the index has occurred, and the same change has not occurred in the master instrument, it will enter in the appropriate direction to "follow" the index. 

 

2ae0b707-2cc8-4090-8c71-b5980bb43554.jpeg

Great example that outlines two short entries for Epic Profits 3 bar and 4 bar play against MNQ on a 3 min chart.

Epic Profits is based on intrabar trade strategy for NinjaTrader which looks initially for a significant engulfing bar (potentially with higher and increasing volume)... Then waits for bar two or three to not go too high past the first engulfing bar, and also not lower than roughly 50% of the previous bar. At this point a market or stop market order is placed on bars 3 or bars 4 if a new higher high (for a long entry) is reached. 

Many of the variables and specifications align with a mentor and stock guru Jared from live traders (special thanks Jared!). You can find how he designs the trade setup here:

https://www.youtube.com/watch?v=Gjj_L0gbUdg

https://www.youtube.com/watch?v=rQmGWPqfG5s&list=PLtwMG9NpaD7QOh50pwmXqjGMzsAojso-w&index=3

https://www.reddit.com/r/Daytrading/comments/hch901/3_bar_play/

Would love to hear everyone feedback or screenshots of trading the 3 bar play with Epic Profits! 

 

 

Epic Bid, is a strategy which keeps an ongoing bid price for your instrument based on the lowest price of the last “x” bars. You can define optional settings such as price offset (above or below that price). 

 This first video covers only a brief summary of Epic Bid indicator and Epic Bid Strategy for NinjaTrader 8. Please check the blog and comments for upcoming videos on NinjaTrader 8 strategy optimzation and best practices with Epic Bid.

TradeCryptoFutures.png

When we first started backtesting Epic Follow I had high expectations between futures and stocks but I was extremly surprised to see the results that came from backtesting cyrpto against futures (and the other way around). Did a big move in NQ/ES affect Bitcoin? Did a significant move in bitcoin affect the Nasdaq? Surely not.... but wait, it looks like it does! 

Most of this strategy trades with tickers I am really not used too... Do you guys trade RTY? 6B? ZW? This was backtested from 01-01-21 to 03-10-21 against Epic Follow and literally all futures are coming up green, but I typically only trade micros and not sure I have the margin to keep these (although strategy is set to close EOD). It does test ok against MES and MNQ but nothing compared to the others I mentioned.

What crypto exchange do you prefer? As we continue to add crypto API's for trading with NinjaTrader, which ones would you prefer to see added?

-Chad

DISCLOSURE: Futures, stocks, and spot currency trading have large potential rewards, but also large potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures, stocks, commodities and forex markets. Don't trade with money you can't afford to lose.

Please remember that past performance may not be indicative of future results. Different types of investments involve varying degrees of risk, and there can be no assurance that the future performance of any specific investment, investment strategy, or product (including utilizing Nash Technologies indicators or back-testing strategies), or any non-investment related content, made reference to directly or indirectly in this commentary will be profitable, equal any corresponding indicated historical performance level(s), be suitable for your portfolio or individual situation, or prove successful. Due to many factors, including changing market conditions and/or applicable laws, the content and software may no longer be reflective of current opinions or positions.

Historical performance results for investment indices, benchmarks, and/or categories have been provided for general informational/comparison purposes only, and generally do not reflect the deduction of transaction charges, the deduction of an investment management fee, nor the impact of taxes, the incurrence of which would have the effect of decreasing historical performance results.  It should not be assumed that your Nash Technologies LLC product, consulting, or service correspond directly to any comparative indices or categories.

Known Limitations / Testimonials: Neither rankings and/or recognition by unaffiliated rating services, publications, media, or other organizations, nor the achievement of any designation or certification, should be construed by a client or prospective client as a guarantee that he/she will experience a certain level of results if Nash Technologies LLC engaged, or continues to be engaged, to provide financial indicators or consulting services. 


Site creation : Dune Interactive