Buy on some date, exit at 1% trailing stop loss
Author: kannett
Creation Date: 4/3/2009 8:44 AM
profile picture

kannett

#1
I would like to do what i think is a pretty simple back test.

Stock XYZ, bought on some date, traded with a 1% trailing stop loss.

Does anyone have an example of such code. Thanks and sorry for such a newbie question.
profile picture

Eugene

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

kannett

#3
Thanks for the response.

Some questions:
1. Where do i define the Bars. Do i need to provide them somehow?
2. Where do i define the Stock i want to test, and the date i want to buy at?
profile picture

Eugene

#4
First you need to download some historical data for the symbol, as you call it, XYZ. Then you need to read the WL User Guide to find out how strategies are executed.

QUOTE:
and the date i want to buy at?

Since "some date" is too vague, code above just enters randomly and exits with a 1% trailing stop. (Keep in mind that one such exit is never enough as some positions will hang indefinitely.)

If you need to use a specific date to buy, then ignore what's above and use this as a starting point:
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).