There are more ways than one to exit a trade in Amibroker. It may sound obvious but trading strategies can benefit from being creative with exits as well as entries.

In this post, I look at a simple way to come up with more flexible sell signals.

Another Way To Sell Using Amibroker

Usually when creating a trading strategy we have precise rules for when to buy and similar rules for when to sell.

For example, we might create a system that buys a stock when RSI(14) crosses 30 and sells when RSI(14) crosses 70. This is about as simple as it gets.

Buy = cross(RSI(14), 30);
Sell = cross(70, RSI(14));

We also have the option of in-built stop losses using the ApplyStop function; fixed stops, trailing stops, profit targets and time-based stops:

ApplyStop(stopTypeLoss, stopModePercent, 20, 1);
ApplyStop(stopTypeTrailing, stopModePoint, 5*ATR(10), 1, 1);
ApplyStop(stopTypeProfit, stopModePercent, 3, 1);
ApplyStop(stopTypeNBar, stopModeBars, 5, 1);

Sometimes, though, it makes sense to combine exit criteria to make exits more conditional or flexible.

One option is to use the ValidFrom and ValidTo arguments to offset or activate various exit criteria at different times.

For example, the following code snippet exits a stock if it is in profit after 5 bars. If it’s not in profit after 5 days, we hold on to the stock and sell it after 10 days instead (this is using the NBar stop).

Buy = Cross(RSI(14), 30);
Sell = 0;
SellPrice = Close;
ApplyStop(stopTypeProfit, stopModePoint, 0.01, 0, False, 0, 5, 5);
ApplyStop(stopTypeNBar, stopModeBars, 10, 1);

Using an exit in this way allows for a little more leeway in trading.

Instead of closing the trade for a loss after 5 days, we give it a little more time to come good. This is one method to increase win rate and hopefully trade expectancy.

The following graphic adds a bit more information about ValidFrom and ValidTo taken from the Amibroker website:

how to sell in amibroker validfrom validto

Obviously there are many combinations and ideas that could be created in this way. And this is without getting into any tricky looping or having to use the CBT.

Being creative with exits could be one way to try and improve your existing trading strategy so it might be worth consideration.



Tags: ,


Leave a Reply

%d bloggers like this: