Buy stock on given date with Trailing stop
Author: The_Viper
Creation Date: 11/15/2013 11:15 AM
profile picture

The_Viper

#1
I have a few questions which on a very basic strategy.

How can I buy a series of stocks on given dates? For example; DXJ on 10/2/13 at end of day, PBF on 11/2/13 at end of day. For all intensive purposes I don’t care what the prices are on that day.

Also I would like add trailing stops for each stock. For example sell individual stocks when they fall by 4% or 5%.

Thank you for your help.
profile picture

Eugene

#2
Here you go. Run this strategy in multi-symbol mode on a DataSet that contains all stocks (DXJ, PBF etc) you intend to buy:

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

The_Viper

#3
Eugene

Wow 11 Minutes response time… I am very impressed!

Thank you
profile picture

pscanlon1

#4
How would you do the trailing stop code like this for a short position? ie, CoverAtTrailingStop

My trailing stop price never changes..

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

Eugene

#5
QUOTE:
My trailing stop price never changes..

That's because it's for longs; for short trades you have to invert it like this:

CODE:
Please log in to see this code.


Hint: create a strategy from Rules, add "Cover at trailing stop", then "Open code in new Strategy window" to see how it's done.

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).