Set a market stop and limit target when entry order is filled

This free NinjaScript strategy  will set a resting stop loss market exit and a limit profit target exit at the time your entry order is filled.

This NinjaScript download is a single zip file that you import directly into NinjaTrader. It’s not assembled which means you have full access to view and change the source code either in NinjaScript Editor or your preferred way to edit .cs files.

Details / Instructions:
You can ignore the entry logic here. The work is being done in the OnPositionUpdate method.

Calculate must be set to on each tick.

If you paste this exit logic into your code, make sure your entries have a signal name that the exits reference. In this case they’re “long” and “short”.

Adjustable variables:
The restingStop and restingTarget variables located in the Dashboard region of the code determine the number of ticks away from the entry price your exit orders will be placed.

This code will not work with releases prior to NinjaTrader 8. Click here if you don’t know how to install NT strategies. Use at your own risk, and backtest backtest backtest before you go live with any strategy.

Leave a Reply

Your email address will not be published. Required fields are marked *