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!

I was recently researching specific algo bots for crypto and came across an interesting setup on YouTube…  The setup seems pretty popular and does backtest out pretty well so I decided to develop a free crypto bot for NinjaTrader and offer it to the algo community! 

The video that I based the algo bot on is below (Note: we are not affiliated in any way with this organization or content, just providing some backstory as to what the setup is based on). https://youtu.be/xbAQR1e1XY8

The basics for the setup...

  1. Add the SSL Channel indicator to a one hour chart … Determine the direction from this (I have included a free NinjaTrader SSL Channel indicator in the download / install). The default settings of “10” are ok for the SSL Channel Period but you can change these in the bot if you desire. 
  2. Add an EMA indicator to a smaller timeframe chart (from his video, a 5 minute chart).  For the setup g from this video he is using a 50 EMA, however you can adjust this within the crypto bot strategy to be any EMA you want. 
  3. Wait for the price on the 5 minute chart to be below the EMA for long entries, or above for short entries (you can choose to have it crossing or below within crypto bot strategy setup). 
  4.  Choose from any bullish or bearish setups for your entry… Within the video he is going with a Engulfing pattern for entry however in the Crypto Bot Strategy you can choose from any of these setups for entry:

a.   Engulfing
b.   Harami
c.   Harami Cross
d.   Belthold
e.   Hammer
f.    Hanging Man
g.   Morning / Evening Star
h.   Rising / Falling Three
i.    Three Soldiers / Crows
j.    Piercing Line
k.   Upside Gap Two Crows
l.    Downside TasukiGap
m.  Dark Cloud Cover

Crypto Bot Strategy (Download Free Below!) 

 

I ended up adding several features to the strategy which can provide optional settings... 

  •  A minute interval for the higher timeframe (default is 60) 
  • Change several other inputs such as the SSL Channel period, EMA, and multiple entry inputs. 
  • Trailing stop loss 
  • Display the upper TF on the lower TF chart (with this you don't really need to ever pull up the upper TF SSL Channel). 
  • Highlight unusual volume (either very minimal or significant) on the chart. At the moment this is only part of the indicator and not the strategy... I am open to input on if anyone thinks these variables would be useful for integration within the strategy. 
  • Ability to enable the algo bot on startup, or based only after clicking a button after its enabled. Also individual buttons to manually go long, short. 

Order Entry Options

  • Optionally only enable long or short entries (or both!)
  • Profit target can be a recent high/low, or standard ticks/currency. 
  • Stop loss can be trailing or static number of ticks/currency.
  • Ability to set stop loss to break even after "X" number of bars.
  • Take profit / exit position after "X" number of bars in your direction.
  • Exit reverse candlestick pattern - Will exit on any reverse pattern! 

 

Backtesting - Below is some historical results with ETH... There are also some great results with BTC and others as well.  

The file is a free download however you do need to register with us to receive the file.

DOWNLOAD CRYPTO BOT STRATEGY FOR NINJATRADER (FREE BOT!)

Hope this is useful for anyone! Please post comments and any feedback!

-Chad

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

EpicSocial_AlgoTrade.png

Hi Algos!

Finished up with an algo related to social trending... There are multiple setups and it does require a little hand holding each morning (importing list of higher volume stocks that are trending).

General setup:

1. Setup is daily / not intraday.

2. Ignitor bar comes from stock that's already trending on twitter/reddit/stock twits and the first high volume day from 'x' days back... such as 200% (or any variable that is back testing well as I still optimize it).

3. Parameter for number of "Pause" bars, awaiting confirmation. Confirmation comes from when trending stock has spiked in activity or sentiment score (tracking 7, 14, 30 day moving average of activity for stocks etc...). If nothing happens with social sentiment within the pause bars, no trade.

4. If during pause bars social sentiment (positive or negative) or activity (number of posts) spikes, entry order is placed (as long as stock has not already went up too much in last 'x' bars.

5. Early exit option when sentiment has dropped while activity has spiked. I am actually not sure on the best exit yet... Could be after number of bars, or maybe after high volume and high wick?

Keeping this setup now only for long as all my backtesting basically represented "no such thing as bad press" and even poor social media sentiment would still lead to spikes... also who wants to be shorting any of these trending stocks, too risky!

Let me know if you have any ideas what have worked for you related to algos for social sentiment, especially best entry/exit setups.

-Chad

Lower studies:

1. Study below volume represents social sentiment (positive / negative discussions towards stocks).

2. Study at the very bottom below the social sentiment is activity (number of posts / mentions of a stock) for the day.

thinkorswim backtesting

If you don't know how your indicator performs historically... why are you using it?

 

Hi fellow traders in the trader-hood! 

Just got the new blog setup and wanted to start the first post off related to one of the most critical topics on indicators for thinkorswim or other platforms like Nina Trader.

For the most part all of our indicators are heavily backtested against multiple timeframes and multiple types of trades from stocks to futures etc... We want to get the absolute best results because, well... we trade with them too! The only indicators we don't have backtesting for are the ones simply related to watchlists or for Epic Labels as these are extremely useful when trading but there really isn't a way to backtest against them. 

If you have been looking around for indicators for a while, you know the biggest problem is that there are so many out there, majority are not documented, and even more important so many of them have not been backtested for a strategy to see if the results for buying and selling a stock would really (historically speaking) work as a successful strategy.  

So as we got started with each indicator we wanted to make sure we had the absolute best options for each indicator and backtesting. This is because trading different stocks or futures really require different setups and small changes can extremely give you very different results. 

Below I will cover the same general settings all of our indicators support, with minor tweaks or changes from indicator to indicator for anything specific to that specific functionality. 

thinkorswim backtesting indicator basic settings

 
  • Enable Backtesting - Although you have added the thinkorswim epic indicator as a "Strategy" and not just a study, you still have the ability to enable and disable backtesting. You must first enable the setting to display backtesting. This allows you to use one strategy on your charts without having to add/remove studies and strategies everytime you want to run some backtesting reports. 
  • Trade Position: - This is to choose if you want to only show testing and strategy reports for buy/long, sell/short or both. Both is enabled by default. 
  • TradeConfirmType - Each of the Epic indicators is a little different, but most of them provide an "early entry" notification option, or a confirmed setup, and then a double confirmation. For example, in the case of Epic Entry this might include ability to see the first higher high after many lower highs as a confirmed setup, however if the bar does not also close above the previous bar then it would be considered a weaker setup. On the other hand, sometimes you you miss out on the best move for the setup because you are entering it late. For this reason we offer multiple setup options for when to enter the position. You should likely test multiple scenerios for the best results... because often an early entry but a closer stop loss can lead to more profitable trades. 
  • Trade Size - Select whatever you feel comfortable with for your normal trading plan. Typically this doesn't matter because the strategy is either profitable or it isn't, so a position size of 1 or 100 isn't going to make a difference, this only changes later if your trading plan is to take a portion off the table and move your stop to break even or trade with brackets for closing out a position etc... note: At the time our indicators and backtesting do not support closing at certain intervals. 
  • Price Type - Used for selecting the entry price or closing price of the position... This can be the open of the next bar, the close, the last price, or mark. Just make sure if you adjust this and see significant changes to the P&L that you also trade based on those same specifics.
  • Use Time Filter - This allows you to select the trading hours that a you trade, or would like to see the profit and loss for... This is useful if you only trade specific hours, or if you want to avoid certain times of trading. So if trading the morning gap is not your trading style... you might consider changing the RTH (regular trading hours) open to be 1030 instead of 930 (if trading was based on EST market open etc..). 
  • RTH Open / RTH Close - The time for open and close based on above settings if you choose to enable the time filter. 

Closing Position Settings

 

Its fair to say that while there might only be a single "open" for a position, the closing the position can be fired by many different setup options, and the first to confirm one of the conditions would then close the position. For example, if you enable the feature to set the last bars high / low as the stop loss, this would likely fire as a stop loss before the fixed dollar amount you might have specified... If you do not hit the target from the fixed dollar amount, or the target percentage, and you do not hit your stop by multiple methods... then if you have the setting enabled to Close EOD it will close your position then. 

  • Close EOD - Certainly a setting that can change the results of your P&L! By default the setting is enabled to close out all positions within the last 'x' minutes of close, you can choose the regular trading hours and hours to close positions in another setting below.
  • Set Last Bar Low Stop Loss - This would set the stop loss to the low of the previous bar.
  • Last Bar Low Stop Loss Offset - This is used in case you want some "wiggle room" for the previous setting for the stop loss. For example, if the stop loss was set to the prior bars low, and that low was $54.25 and the offset setting was set to .50, then actually it would set the stop loss to $54.75. This is useful because often the stop loss might hit or the low might hit the exact amount of the previous candle and this provides some room to breath. 
  • Close Position On Reversal Indicator = This would work as a stop loss if during the process the setup created an order in the opposite direction. For example if you are trading 5 minute pivots and have a long target and stop loss that has not been met however a separate pivot has indicated an order in the opposite direction this would close the position. 
  • Close Position X Bars Past - Option to close the position if "x" bars have passed with the price going in the opposite direction as your trade. So if the you set this to be 5 and no other target or stop loss was triggered, it would trigger after 5 bars in the opposite direction of your trade. 
  • Bar Exit - Based on the setting above, when its enabled this number is "x" for how many bars in the opposite direction should be checked. 
  • Close Position Trail Stop - Typically used when all other stop loss's are not set and you simply want to let your trade "run" or close out EOD. You can set a trailing stop dollar amount and it will close out based on trailing dollar. 
  • Close Position Trail Stop Dollar - The dollar amount used when trailing stop is enabled. For example if your long entry was $50.00 and you had a trailing stop of $3.00, if the stock immediately dropped to $47 it would close out, or if the stock went all the way up to $65 and then at some point dropped down to $62.00 then it would close the position. 
  • Enable Scalp Long / Short- The scalp feature when enabled will close 1/2 of the position if that target is reached. 
  • Scalp Amount Long / Short - The amount that corresponds to to the setting above when scalp feature is enabled. So if you have a target set to $5.00 and the scalp is set to $2.00, it will close half of the position at the $2.00 target. 
  • Enable Target Long / Short  - Set as "Order Cancels Order" but really its just the target and stop loss, the target can be triggered by either percent or dollar amount (whichever fires first). So if you want the target to be set by target percent, then just set the target dollar amount to an extremely high dollar amount. 
  • Target Percent Ratio  - The percent ratio to use as the target to close position. 
  • Target Price - The  dollar amount to use as the target to close the position.
  • Stop Price - The dollar amount to be set as the stop loss to automatically close the position. 

Hope this is helpful! 

-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