NexusFi: Find Your Edge


Home Menu

 





Trailing Stop Loss - EasyLanguage


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one tradestation18 with 3 posts (1 thanks)
    2. looks_two Shaban with 1 posts (1 thanks)
    3. looks_3 kevinkdog with 1 posts (0 thanks)
    4. looks_4 FuManChou with 1 posts (0 thanks)
    1. trending_up 4,493 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

Trailing Stop Loss - EasyLanguage

  #1 (permalink)
tradestation18
Porto Portugal
 
Posts: 16 since May 2018
Thanks Given: 1
Thanks Received: 1

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

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
  #2 (permalink)
 
FuManChou's Avatar
 FuManChou 
Saint Paul, Minnesota, United States
 
Experience: Beginner
Platform: MultiCharts
Broker: Edge Clear LLC
Trading: MNQ
Posts: 100 since Jun 2019
Thanks Given: 1,127
Thanks Received: 120

Try this.

inputs:
TrailingAmount$(0);

If TrailingAmount$ > 0 then
SetDollarTrailing(TrailingAmount$);

Reply With Quote
  #3 (permalink)
tradestation18
Porto Portugal
 
Posts: 16 since May 2018
Thanks Given: 1
Thanks Received: 1


Thanks, but SetDollarTrailing is a profit taking strategy.
What I look for is a Stop Loss Trailing strategy...

Reply With Quote
  #4 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,648 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


tradestation18 View Post
Thanks, but SetDollarTrailing is a profit taking strategy.
What I look for is a Stop Loss Trailing strategy...

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.

Follow me on Twitter Reply With Quote
  #5 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

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

---------------------------------------------------------------------

Inputs: StopMult(3);
Vars: mystop(0);



mystop=StopMult*AvgTrueRange(14)*BigPointValue;
if mystop>0 then setstoploss (mystop);

------------------------------------------------------------------------

P. S: I sent you a P.M.

Reply With Quote
Thanked by:
  #6 (permalink)
tradestation18
Porto Portugal
 
Posts: 16 since May 2018
Thanks Given: 1
Thanks Received: 1

Thanks all for your comments. The best trailing stop loss I have come to is something like this:

inputs:
PositionBasis( true ),
Amount ( 0 ),
Trailingpercent (0) ;

Variables: TrailValue(0),TrailExit(0);


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

Reply With Quote
Thanked by:




Last Updated on June 1, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts