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!

NashTech_Strategy_WaitXBarsBeforeReentry.jpeg

Feature: Wait X Bars from Last Exit

Benefits: Avoid continued entry and/or exit, possibly in market conditions that are not suitable for the trading strategy. 

We code a log of NinjaTrader strategies... and we like to provide tips for other developers or traders wanting to create custom strategies for NinjaTrader. 

Sometimes the market doesn't always respond well to your algo strategy... In that situation, you want to avoid entry, often for money management and controlling your trading strategy. We use a special feature within NinjaTrader for this.

We include this feature within all of the Epic NinjaTrader Indicators and strategies but you can reference the same code below:

Within OnStateChange()


BarsRequiredBeforeReEntry = 5;

 

Within Properties:


[NinjaScriptProperty]
[Display(Name = "Bars Required Before ReEntry", Order = 1, GroupName = "NashTech Order Entry")]
public int BarsRequiredBeforeReEntry
 { get; set; }

Within OnBarUpdate:


int BarsSinceExit;
BarsSinceExit = 0; 

 if (BarsSinceExitExecution() != -1)
                {

        BarsSinceExit = BarsSinceExitExecution();
           
                    if (BarsSinceExit < BarsRequiredBeforeReEntry)
                    {
                        if (EnableDebugMode == true)
                        {
                            Print("We should only be here if bars required before re-entry is less than bars since exit");
                            Print("Bars Since Exit Execution:" + BarsSinceExit);
                            Print("Required Before ReEntry:" + BarsRequiredBeforeReEntry);
                            Print("Time of Skipping order:" + Time[0]);
                        }
                    
                        BarBrushes[0] = PendingBrush;

                        return;
                    }

                }

 

 

Questions? Leave a comment! 

 

-Chad

All subscribers and lifetime license users get the latest templates to install based on our weekly optimization results. If there is an instrument you want the most recent template for, just ask! For trial users all templates are about 30 days old.

Often we get requests to help with Ninjascript / NinjaTrader 8 indicators and strategies that do not always fit within our required work for engagement... This does not mean we don't want to be helpful! We always encourage algo trading and want to help novices and customers alike with best practices. We will continue to work on videos but are also planning weekly videos on best practices. 

Within each of our custom NinjaTrader straegies we often include some basic setup configurations... These include:

  • Wait X Bars from new trading day
  • Wait X Bars from last exit
  • Exit after X Bars 
  • Setup Stop Loss to Breakeven after X Bars
  • Exit after reverse tail (topping / bottoming wick/tail)
For the next few months we will continue to post a solution to each of these... for now here are some code examples for this.
 
Within OnStateChange:
   WaitXBarsFromNewTradingDay = 10;
 
WithinOnBarUpdate:
                if (Bars.BarsSinceNewTradingDay < WaitXBarsFromNewTradingDay && Position.MarketPosition == MarketPosition.Flat && EnableDebugMode == true)
                {
                    Print("RETURNING Bars Since new day has not fired... We will skip this order because we are currently flat in the market. ");
                    Print("Wait X Bars from new trading day: " + WaitXBarsFromNewTradingDay);
                    Print("Bars since new trading day: " + Bars.BarsSinceNewTradingDay);
                    BarBrushes[0] = DaysFromTradingDayBrush;
                    StrengthCandles1.BarBrushes[0] = DaysFromTradingDayBrush;
                    return;
                }
 
Within config properties:
 [NinjaScriptProperty]
        [Display(Name = "Wait X Bars From New Trading Day", Order = 16, GroupName = "Order Entry")]
        public int WaitXBarsFromNewTradingDay
        { get; set; }
 
Wanting a code example we are not including here? Let us know how we can help.
 
Chad
 

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. 

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.

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