This strategy performs reversal trading based on pivot point breakouts. It calculates the pivot high and pivot low over a specified period to determine the pivot levels. It goes short when the price breaks above the pivot high, and goes long when the price breaks below the pivot low. This is a typical short-term mean reversion strategy.
The core logic of this strategy is to calculate the pivot high and low points. The formulas are:
Pivot High = Sum of highest high over the past N1 bars / N1
Pivot Low = Sum of lowest low over the past N2 bars / N2
Where N1 and N2 are parameters that define the number of bars used to calculate the pivot points.
After obtaining the pivot high/low levels, the trading rules are:
So it realizes a short-term reversal strategy based on pivot point breakouts.
The advantages of this simple strategy are:
There are some risks:
These risks can be managed by parameter tuning, applying exit rules etc.
There is large room for optimization:
In summary, this is a very simple short-term pivot reversal strategy. Its advantages are simplicity and ability to capture reversals. But there are some risks that need to be addressed through optimization. Overall this serves as a good practice strategy for beginners and builds foundation for advanced strategies.
/*backtest start: 2023-12-01 00:00:00 end: 2023-12-31 23:59:59 period: 2h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy("Pivot Reversal Strategy - FIGS & DATES 2.0", overlay=true, pyramiding=0, initial_capital=10000, currency="USD", default_qty_type=strategy.percent_of_equity, default_qty_value=100.0, commission_value=0.075) leftBars = input(4) rightBars = input(2) // backtesting date range from_day = input(defval=1, title="From Day", minval=1, maxval=31) from_month = input(defval=1, title="From Month", minval=1, maxval=12) from_year = input(defval=2018, title="From Year", minval=1900) to_day = input(defval=1, title="To Day", minval=1, maxval=31) to_month = input(defval=1, title="To Month", minval=1, maxval=12) to_year = input(defval=9999, title="To Year", minval=1900) time_cond = true swh = pivothigh(leftBars, rightBars) swl = pivotlow(leftBars, rightBars) middle = (swh+swl)/2 swh_cond = not na(swh) hprice = 0.0 hprice := swh_cond ? swh : hprice[1] le = false le := swh_cond ? true : le[1] and high > hprice ? false : le[1] if le and time_cond strategy.entry("LONG", strategy.long, comment="LONG", stop=hprice + syminfo.mintick) swl_cond = not na(swl) lprice = 0.0 lprice := swl_cond ? swl : lprice[1] se = false se := swl_cond ? true : se[1] and low < lprice ? false : se[1] if se and time_cond strategy.entry("SHORT", strategy.short, comment="SHORT", stop=lprice - syminfo.mintick) //plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)