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?
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.
In OnBarUpdate()
The following user says Thank You to deefster for this post:
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.