NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-10-2010, 09:04 PM   #1
ariliveitup
Junior Member
 
Join Date: Mar 2010
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default SetStopLoss and SetTrailStop simulate together

I have visited the Advanced Order Handling section and I understand that SetStopLoss and SetTrailStop cannot be used concurrently for the same position, however I was wondering if there is workaround.

http://www.ninjatrader-support.com/H...dOrderHandling

This is what I am looking to do:

/***** Pseudocode below ***
double profitTarget = 8; // Ticks
double stopLoss = 8 // Ticks

Lets say I buy S&P Eminis for a 1000

I would like to immediately put out a stopOrder for 1000 - 8 ticks = 998

I believe I can do this in OnExecution( )
SetStopLoss

However when my PNL = 1000 + (profitTarget )8 ticks = 1002, I would want to cancel the StopLoss Order and generate a Trailing Stop Loss (trailing stop loss order by 8 ticks)

I do not want to start trailing right away because, the i want to allow 8 ticks of downside in the beginning and only after the simulated profit target is reached, I want to start trailing.

Given the fact that there are no references returned for stoploss orders, how do i cancel the stop loss order and send a trailing
ariliveitup is offline  
Reply With Quote
Old 03-11-2010, 05:11 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
Default

ariliveitup, welcome to our forums - I would suggest you check into this sample below, as it deals with setting a static initial stop loss and then adjusting the set stop to provided the trailing functionality, all with using SetStopLoss only -

http://www.ninjatrader-support2.com/...ead.php?t=3222
NinjaTrader_Bertrand is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simulate Partial fill ... with ease. ltemme Automated Trading 4 08-16-2008 10:04 AM
How to SetStopLoss and SetTrailStop cassb Strategy Development 14 08-03-2008 09:19 PM
SetStopLoss() & SetTrailStop() Concurrent Use whitmark Strategy Development 8 11-14-2007 09:05 AM
SetTrailStop & SetStopLoss question woodside Strategy Development 1 11-06-2007 03:41 PM
simulate stock trade sunnyrain ATM Strategies (Discretionary Trading) 5 10-11-2007 12:12 PM


All times are GMT -6. The time now is 11:00 PM.