Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hi,
Canīt find any pre-build code in TradeStation for Trailing Stop Loss strategy. Can someone help to get the code in EL for Trailing Stop Loss strategy?
Thanks
Can you help answer these questions from other members on NexusFi?
SetDollarTrailing is a trailing STOP, not a profit target.
In any event, I would not recommend SetDollarTrailing or SetPercentTrailing for any backtesting, unless you use 1 tick LIBB. It gives inaccurate results otherwise.
From Tradestation Help File:
SetDollarTrailing (Reserved Word)
image\trumpet2.gif Disclaimer
This built-in stop reserved word is used to set a trailing stop to exit a position based on a specified dollar Amount that trails the greatest position profit. A stop order is generated at the calculated price based on the trailing Amount.
SetDollarTrailing(Amount)
Amount is the greatest open position profit that you are willing to give back.
Use with SetStopContract or SetStopPosition.
Strategy
Dollar Risk Trailing
Example
To place a dollar risk trailing stop at $500 for the entire position, write:
SetDollarTrailing(500);
As the price rises in a long position, so does the placement of the stop. It is maintained at a dollar value that results in a total of $500 loss for the entire position.
Additional Example
To place a dollar risk trailing stop at $5 below the greatest share price, write:
SetStopShare;
SetDollarTrailing(5);
As the price rises in a long position, so does the placement of the stop. It is maintained at a stop value $5 below the greatest share price.
If it is helpful, this is a Stop loss that is based on volatility with the ATR (however, be careful, because if volatility increases, the Stop loss also increases):
if PositionBasis then
SetStopPosition
else
SetStopShare ;
SetStopLoss( Amount ) ;
If marketposition>=1 and currentbar>2 then begin
TrailValue=Highest(High,BarsSinceEntry);
TrailExit=TrailValue-Trailingpercent*0.01*Close;
If Close<=TrailExit then sell ("LX") next bar at market;
end;
If marketposition<=-1 and currentbar>2 then begin
TrailValue=Lowest(Low,BarsSinceEntry);
TrailExit=TrailValue+Trailingpercent*0.01*Close;
If Close>=TrailExit then buy to cover ("SX") next bar at market;
end;