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 futures io?
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;
Regards
The following user says Thank You to tradestation18 for this post: