How to create a boolean expression similar to SellAtTrailingStop ?
Author: sofia
Creation Date: 3/13/2015 12:24 PM
profile picture

sofia

#1
Hello,

Is it possible to create boolean expression which is similar to SellAtTrailingStop ?
i.e instead of using "SellAtTrailingStop", use bool condition with SellAtMarket
But they don't give same results.

I tried replacing this


CODE:
Please log in to see this code.


with this
CODE:
Please log in to see this code.


Thanks,

Sofia
profile picture

Cone

#2
Anything's possible. The right question is "How do I ..." ;)

Like SellAtTrailingStop does, you just have to keep track of the highest value of the stop during the life of the Position and use that value in your condition.
profile picture

sofia

#3
Thanks, but how do I code it. Can you please help.
profile picture

Eugene

#4
QUOTE:
But they don't give same results.


If you open the QuickRef, you'll see the difference. SellAtTrailingStop is not equal to selling at market after a crossunder: it maintains a level that can't go down (unlike SellAtStop, for example). You might want to add a PlotStops() to visualize stop/limit exits.

Additionally, your SellAtMarket does not have a chance to trigger. A closing price can not be lower than the 20-day lowest close. The level has to be shifted one bar ahead:

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

Eugene

#5
QUOTE:
Thanks, but how do I code it. Can you please help.

For example:
CODE:
Please log in to see this code.
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).