how to plot trailing stop
Author: dankimel
Creation Date: 1/13/2011 11:25 AM
profile picture

dankimel

#1
I have the following trailing stop statement in one of my strategies:
CODE:
Please log in to see this code.


How do you plot the trailing stop on the PricePane?
profile picture

Eugene

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

dankimel

#3
OK, that gives me a point.

What I want is a continuous curve of the value of the trailing stop for past bars up to the present so I can look at the curve and see right away how far the stock is away from the trailing stop for today's bar.
profile picture

Cone

#4
You can either:
1. Make DataSeries of stop values and PlotSeries, or,

2. Use DrawLine() to connect the dots.

If you do #1, make sure to fill the series with some value (like the most recent stop) so that it doesn't plot at the zero level and distort the scaling.
profile picture

sedelstein

#5
I am new to Wealth-lab. Trying to do too many things at once, learning the language, reading the online guides, trying some of the canned strategies, etc...

I'm trying to write the following stop rule

Initial stop at position entry price less (for longs) some multiple of an n day ATR
Subsequent stops at the higher of previous stop or the previous days high less some multiple of that days n-day ATR

I appreciate the help (and the learning experience for me) if someone can display that relatively painlessly

Thanks!
profile picture

Cone

#6
PlotStops() is pretty painless, isn't it?

QUOTE:
so I can look at the curve and see right away how far the stock is away from the trailing stop for today's bar
The dots show precisely the price at which a stop will take place on the bar plotted. It's exactly what you want except that they're dots, not a line.
profile picture

Eugene

#7
Have you tried the canned Bandwagon Trade strategy? Its code can serve as a good illustration of mostly all what you requested. Also you might like to replace SellAtStop/CoverAtStop with SellAtTrailingStop/CoverAtTrailingStop to better suit the "at the higher of previous stop..." part.
profile picture

sedelstein

#8
Will look

Thanks!
profile picture

dankimel

#9
Cone, you're right. PlotStops() does exactly what I want. Thanks, Eugene.
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).