SellAtTrailingStop()
Author: zanek
Creation Date: 6/24/2009 11:11 PM
profile picture

zanek

#1
In the WealthLab QuickReference guide, it says that for "SellAtTrailingStop()" that "The trailing stop price is maintained with the Position, and it is modified only when the specified stopPrice is above the current trailing stop price. "

Assuming you bought a stock at say $10, does that mean if you call SellAtTrailingStop() once with a stopPrice of $9 and then later call SellAtTrailingStop() with a stopPrice of $9.50 that the old stopPrice of $9 will be replaced with the new stopPrice of $9.50 for the trailing stop ?

In the code example in the QuickRef guide, there is a call to SellAtStop() and then SellAtTrailingStop(), so I'm unsure about the logic in the code below since the example is selling at a stop and then calling a function to sell at trailing stop again.

CODE:
Please log in to see this code.
profile picture

Cone

#2
QUOTE:
does that mean if you call SellAtTrailingStop() once with a stopPrice of $9 and then later call SellAtTrailingStop() with a stopPrice of $9.50 that the old stopPrice of $9 will be replaced with the new stopPrice of $9.50 for the trailing stop ?
Not only does it mean that, if after you set a T-stop price of 9.50 you pass 9.25, it still maintains 9.50 as the stop trigger price. In other words, you don't have to keep track of the most-stringent stop price with this signal, it does it for you.

QUOTE:
I'm unsure about the logic in the code below since the example is selling at a stop and then calling a function to sell at trailing stop again.
They're [almost surely] two different stop prices, so whichever one is hit will trigger the exit. In backtesting, if both signals would have resulted in the an exit, the first one executed (the SellAtStop) will be the one that exits the position.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).