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 06-16-2007, 10:06 AM   #1
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default Get Prevailing Stop Prices for SetTrailStop()

Is there a way for me to GET the prevailing stop price used by the SetTrailStop method such that I can track the value at the close of each bar for debugging purposes? I am setting an initial trailing stop using CalculationMode.Ticks in Initialize() and when Flat but when in an open position, will reduce the amount of the trailing stop within OnBarUpdate() when a certain profit objective is met. It does not appear that the subsequent ratcheted trailing stop is working correctly. Thanks.

Whitmark
whitmark is offline  
Reply With Quote
Old 06-16-2007, 11:03 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Unfortunately not at this time. Possibly in the fall since we are introducing some new concepts that allow you to get back order information.
NinjaTrader_Ray is offline  
Reply With Quote
Old 06-16-2007, 11:27 AM   #3
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

The help on SetTrailStop() states:

Quote:
You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the trail stop price while in an open position
Is there an open issue with using SetTrailStop() dynamically for an open position in the manner I descibed earlier? For this to work dynamically, is it required that I supply all the parameters especially the fromEntrySignal? Do I need to restate the command on each bar?
SetTrailStop(string fromEntrySignal, CalculationMode mode, double value, bool simulated)
If there is an issue, is there a recommended work around?

Also, in this context, CalculationModes of "Percent" and "Ticks" make sense as a trailing stop offset, but how is the mode "Price" used?

Thanks,

Whitmark
Last edited by whitmark; 06-16-2007 at 11:33 AM.
whitmark is offline  
Reply With Quote
Old 06-16-2007, 12:41 PM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

All parameters are required and the method only needs to be called once, not each bar. Price is used as an absolute value. If you passed in "2" and you were trading MSFT, that would be $2 offset which is the same as a 200 tick offset.
NinjaTrader_Ray is offline  
Reply With Quote
Old 06-17-2007, 08:12 AM   #5
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

The help shows multiple syntax versions so its helpful to know when to use appropriate one. I've noticed the wizard uses the last one.

Quote:
Syntax
SetTrailStop(double currency)
SetTrailStop(double currency, bool simulated)
SetTrailStop(CalculationMode mode, double value)
SetTrailStop(string fromEntrySignal, CalculationMode mode, double value, bool simulated)
Seems as though my issues with SetTrailStop() working has to do with the concurrent use of SetStopLoss(). While testing, I can SetTrailStop() to just a few ticks and see that a named "Trail stop" order takes me out of most trades. However, when I add a SetStopLoss(), even with a huge stop loss setting, it appears that that SetTrailStop processing is suppressed and I no longer see any "Trail stop" orders being submitted although my trailing stop level has been breached.

I am not aware of any restrictions regarding the concurrent use of StopLoss() and SetTrailStop(), and there are certainly instances where you would want to manage the two differently, particularly in a dynamic manner. Please advise.

Thanks,

Whitmark
whitmark is offline  
Reply With Quote
Old 06-17-2007, 08:42 AM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

The first called likely will take precedence if the fromEntrySignal name is the same...both will not operate simultaneously on the same signal name. If they are different, then they will operate independantly.
NinjaTrader_Ray is offline  
Reply With Quote
Old 06-17-2007, 09:44 AM   #7
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

Thanks Ray,

Are you stating that if you place an order in a strategy (regardless if whether you specify it with a fromEntryName or not) that you cannot apply both a SetStopLoss() and SetTrailStop() to it?

From my testing, it doesn't seem to matter what sequence they are initialized, SetStopLoss() will take precedence when both are used and render SetTrailStop() processing inoperable. This nuance, including the insight that a specified or non-specified fromEntryName can utilize SetStopLoss() or SetTrailStop() but not both, should be clarified in the Help facility.

Whitmark
Last edited by whitmark; 06-17-2007 at 10:12 AM.
whitmark is offline  
Reply With Quote
Old 06-18-2007, 02:02 PM   #8
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

This discussion has evolved to another thread to be continued on:

http://www.ninjatrader-support.com/v...ead.php?t=2426
whitmark 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
Superdom Prices?? Tripspike SuperDOM and other Order Entry Windows 5 06-15-2007 01:12 PM
SetTrailStop() funk101 Strategy Development 1 04-04-2007 03:39 AM
setTrailStop() not executing funk101 Strategy Development 1 04-02-2007 08:32 AM
SetTrailStop() funk101 Strategy Development 8 03-27-2007 07:42 AM
Adjust displayed dom prices jim c ATM Strategies (Discretionary Trading) 1 03-30-2005 01:09 AM


All times are GMT -6. The time now is 06:49 PM.