When Should You Exit A Trade? 5 Trading Exit Strategies You Can Use (Amibroker Code)

The article could be found here.

 

The strategy in plain English:

  1. Enter at the close if the two-day RSI is below 10.
  2. Exit at the close when the two-day RSI is above 90.

We test this strategy with many different stops:

  • Time stop
  • Stop loss
  • Trailing stop
  • Profit target

 

Amibroker code:

 

setOption(“holdminbars”,1);

oddis=Optimize(“Time based exit”,10,1,15,1);  //this optimzes the different settings for each stop (see below)

Buy= RSI(2)<10;
BuyPrice=Close;
Sell=RSI(2)>90;
SellPrice=Close;
//ApplyStop(stopTypeNBar,stopModeBars,oddis,1) ;  //time stop
//ApplyStop(stopTypeLoss,stopModePercent,oddis,1);  //stop loss
//ApplyStop(stopTypeTrailing,stopModePercent,oddis,1); //trailing stop
//ApplyStop(stopTypeProfit,stopModePercent,oddis,1);  //profit target

 

Random entry:

 

Buy= Random()<.1 ;
BuyPrice=Close;
Sell=RSI(2)>90;
SellPrice=Close;

 

 

Disclaimer: We are not financial advisors. Please do your own due diligence and investment research or consult a financial professional. All articles are our opinions – they are not suggestions to buy or sell any securities.