NexusFi: Find Your Edge


Home Menu

 





Stop Close Only Ninjatrader


Discussion in NinjaTrader

Updated
    1. trending_up 1,229 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?
MC PL editor upgrade
MultiCharts
Quantum physics & Trading dynamics
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
What broker to use for trading palladium futures
Commodities
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
24 thanks
What is Markets Chat (markets.chat) real-time trading ro …
19 thanks
ApexTraderFunding.com experience and review
17 thanks
GFIs1 1 DAX trade per day journal
13 thanks
EG Indicators
11 thanks
  #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