Stop Close Only Ninjatrader - futures io
futures io futures trading

Stop Close Only Ninjatrader

Discussion in NinjaTrader

    1. trending_up 805 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 1 attachments

Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

Search this Thread

Stop Close Only Ninjatrader

(login for full post details)
  #1 (permalink)
Experience: None
Platform: NT
Trading: ES
Posts: 10 since Jan 2014
Thanks: 4 given, 0 received

Hi guys, I'd like to implement stop close only order in ninjatrader and was wondering if anyone has done this already and would care to share a few bits of code/info. I'm new to ninjatrader and the only sensible way I could think of is to implement a variable which tracks the stop and in OnBarUpdate() if the close falls below (for long positions) and above (for short positions) exit the position immediately. I know there is probably a better way of doing this with perhaps simulated stops. Does anyone have any experience with this?

Please help !

Thanks in advance.

Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(167 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
(login for full post details)
  #3 (permalink)
Experience: Intermediate
Platform: TOS, TDA StrategyDesk
Broker: TD Ameritrade
Trading: equities,options
deefster's Avatar
Posts: 14 since Dec 2009
Thanks: 10 given, 9 received

Seems to me if you have CalculateOnBarClose = true, such as in Initialize(), then you can simply just refer to the prior close to meet your criteria. Take a look at some of the sample strategies, but I'm thinking something like below should work, obviously do some paper trades before trying anything live.

#region Variables
private IOrder entryOrder = null; // variable used to track order status
private IOrder exitOrder = null; // variable used to track order status
private double PainLevel = 10*TickSize;

In OnBarUpdate()

if (your_entrycondition) {
 entryOrder = EnterLong();

if (entryOrder.OrderState == OrderState.Filled && CrossBelow(close[1], entryOrder.AvgFillPrice - PainLevel,1))
  exitOrder = ExitLong();

Reply With Quote
The following user says Thank You to deefster for this post:
(login for full post details)
  #4 (permalink)
Experience: None
Platform: NT
Trading: ES
Posts: 10 since Jan 2014
Thanks: 4 given, 0 received

Thanks deefster. It makes sense now. I incorporated your suggestions into Ninjatrader's SampleOnOrderUpdate strategy so as to create a strategy which initially uses a stop close only order.

I've attached it so you or others can use/modify at their leisure. You are welcome to give any suggestions for improvement as you see fit.


Attached Files
Register to download File Type: zip (4.1 KB, 14 views)
Started this thread Reply With Quote

futures io Trading Community Platforms and Indicators NinjaTrader > Stop Close Only Ninjatrader

Last Updated on January 25, 2014

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


Journal Challenge w/$1500 prizes from Topstep!


Battlestations! Show us your trading desk - $1,500 in prizes!


Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only

Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts