View Full Version : Get Prevailing Stop Prices for SetTrailStop()
whitmark
06-16-2007, 10:06 AM
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
NinjaTrader_Ray
06-16-2007, 11:03 AM
Unfortunately not at this time. Possibly in the fall since we are introducing some new concepts that allow you to get back order information.
whitmark
06-16-2007, 11:27 AM
The help on SetTrailStop() states:
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
NinjaTrader_Ray
06-16-2007, 12:41 PM
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.
whitmark
06-17-2007, 08:12 AM
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.
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
NinjaTrader_Ray
06-17-2007, 08:42 AM
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.
whitmark
06-17-2007, 09:44 AM
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
whitmark
06-18-2007, 02:02 PM
This discussion has evolved to another thread to be continued on:
http://www.ninjatrader-support.com/vb/showthread.php?t=2426