The Reversal Tracking strategy is a trend tracking strategy that combines moving averages as market filters. It establishes positions when price reversal signals occur to implement buy low and sell high, tracking the trend after price reversals to gain excess returns.
The core logic of this strategy is: establishing long positions when the close is lower than the low N days ago; closing long positions when the close is higher than the high N days ago. It also combines the 200-day simple moving average as a market filter - long positions are only established when prices are above the 200-day moving average.
This strategy is based on price reversal theory, which believes that trends in stock prices will repeatedly show highs and lows. When prices break below the low formed N days ago, it is time to establish long positions; when prices break above the high N days ago, it indicates that the reversal uptrend has ended and it is time to take profits.
Specifically, the core modules of this strategy are:
Market Filter
Use the 200-day simple moving average to judge market trends. Allow establishing positions only when stock prices are above the 200-day line. This avoids establishing short positions in a bull market or establishing long positions in a bear market.
Reversal Signal Judgement
Logic: Close < Lowest price N days ago
If the close is lower than the lowest price N days ago (default 5 days), it indicates a downside price breakdown and triggers a buy signal.
Take Profit Signal Judgement
Logic: Close > Highest price N days ago
If the close is higher than the highest price N days ago (default 5 days), it indicates the reversal uptrend has ended and triggers a take profit signal.
5% Stop Loss
Set a 5% stop loss line from the entry price to avoid excessive losses.
The main advantages of this strategy are:
There are also some risks with this strategy:
The strategy can be optimized in the following aspects:
The Reversal Tracking Strategy combines moving average indicators to determine market conditions and utilizes reversal theory to select entry timing. The risk control mechanisms of take profit and stop loss target excess returns by buying low and selling high. The strategy can be improved through parameter optimization, adding auxiliary filters, etc. It can achieve good returns in trending markets.
/*backtest start: 2024-01-06 00:00:00 end: 2024-02-05 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // @version=4 // © HermanBrummer // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // BUYS WHEN THE CLOSE IS SMALLER THAN THE LOW OF 5 DAYS AGO // SELLS WHEN THE CLOSE IS HIGHER THEN THE HIGH OF 5 DAYS AGO // USES A 200 MOVING AVERGE AS A FILTER, AND DOESN'T TAKE TRADES IF THE MARKET IS BELOW IT'S 200 MA // USES A 5% STOP LOSS FROM ENTRIES strategy("REVERSALS", overlay=true) StopLoss = input(.95, step=0.01) HowManyBars = input( 5 ) /// EXITS if close > sma(high,HowManyBars)[1] strategy.close_all() /// ENTRIES MarketFilter = sma(close, 200) F1 = close < sma(low,HowManyBars)[1] F2 = close > MarketFilter plot(MarketFilter, "MarketFilter", color.yellow) strategy.entry("Long", true, 1, when=F1 and F2) /// STOP LOSS StopLossLine = strategy.position_avg_price * StopLoss plot(StopLossLine, "StopLossLine", #FF0000) strategy.exit("Exit", stop=StopLossLine)template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6