NexusFi: Find Your Edge


Home Menu

 





Stop Close Only Ninjatrader


Discussion in NinjaTrader

Updated
    1. trending_up 1,221 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread

Stop Close Only Ninjatrader

  #1 (permalink)
 cruelGlad 
TORONTO CANADA
 
Experience: None
Platform: NT
Trading: ES
Posts: 10 since Jan 2014
Thanks Given: 4
Thanks Received: 0

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

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Quant vue
Trading Reviews and Vendors
MC PL editor upgrade
MultiCharts
What broker to use for trading palladium futures
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #3 (permalink)
 
deefster's Avatar
 deefster 
Denver
 
Experience: Intermediate
Platform: TOS, TDA StrategyDesk
Broker: TD Ameritrade
Trading: equities,options
Posts: 14 since Dec 2009
Thanks Given: 10
Thanks Received: 9


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.

 
Code
#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()

 
Code
if (your_entrycondition) {
 entryOrder = EnterLong();
}

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

Reply With Quote
Thanked by:
  #4 (permalink)
 cruelGlad 
TORONTO CANADA
 
Experience: None
Platform: NT
Trading: ES
Posts: 10 since Jan 2014
Thanks Given: 4
Thanks Received: 0

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.

Cheers.

Attached Files
Elite Membership required to download: SCO.zip
Started this thread Reply With Quote




Last Updated on January 25, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts