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.

Showing 0 Comment


Comments are closed.

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