123 Pattern Reversal Strategy (Amibroker And Tradestation Code)
The original article can be found here.
Bullish reversal:
- Today’s low must be lower than yesterday’s
- Yesterday’s low is lower than the low three days ago
- The low two days ago is lower than the low three days ago
- The high two days ago is lower than the high three days ago
Amibroker code:
oddis=Optimize("Trading day",20,1,25,1);
Buy = Ref(H,-2)<Ref(H,-3) AND Ref(L,-2)>Ref(L,-3) AND Ref(L,-1)<Ref(L,-3) AND L<Ref(L,-1);
buyPrice = Close;
Sell = 0;
sellPrice = Close ;
applyStop(stopTypeNBar,stopModeBars,oddis,1);
Tradestation code bullish reversal:
{
Strategy - 123 pattern reversal bullish
https://www.quantifiedstrategies.com/lessons/123-pattern-reversal-strategy-amibroker-code/}
Inputs:
HoldBars(20);
if H[2] < H[3] AND L[2] > L[3] AND L[1] < L[3] AND L < L[1] Then
buy this bar on close;
if Barssinceentry(0) >= HoldBars Then
sell this bar on close;
Bearish reversal:
- Today’s high must be higher than yesterday’s high
- Yesterday’s high is higher than the high three days ago
- The low two days ago is lower than the low three days ago
- The high two days ago is lower than the high three days ago
oddis=Optimize("Trading day",20,1,25,1);
Buy = Ref(H,-2)<Ref(H,-3) AND Ref(L,-2)>Ref(L,-3) AND Ref(H,-1)>Ref(H,-3) AND H>Ref(H,-1);
buyPrice = Close;
Sell = 0;
sellPrice = Close ;
applyStop(stopTypeNBar,stopModeBars,oddis,1);
Tradestation code bearish reversal:
{
Strategy - 123 pattern reversal bearish
https://www.quantifiedstrategies.com/lessons/123-pattern-reversal-strategy-amibroker-code/}
Inputs:
HoldBars(10);
if H[2] < H[3] AND L[2] > L[3] AND H[1] > H[3] AND H > H[1] Then
buy this bar on close;
if Barssinceentry(0) >= HoldBars Then
sell this bar on close;
