Consecutive Up/Down N Days Strategy
Consecutive Up/Down N Days Strategy
This article will introduce in detail the trading logic, pros, potential risks and summary of the Consecutive Up/Down N Days strategy.
This is a long-only strategy that determines entries and exits based on user-defined consecutive up days and consecutive down days. The trading logic is very straightforward.
Strategy Logic
Firstly, we need to set two parameters:
consecutiveBarsUp: consecutive up days
consecutiveBarsDown: consecutive down days
Then we record two variables:
ups: current consecutive up days
dns: current consecutive down days
Each day we compare the close price with previous close to determine if it's an up day or down day. If up, ups + 1, if down, dns + 1.
When ups reaches consecutiveBarsUp, we go long. When dns reaches consecutiveBarsDown, we exit positions.
That's the simple logic for a consecutive up/down strategy. We only go long after consecutive up days from bottom. And exit after consecutive down days. This avoids frequent trading in range-bound markets.
Pros
-
Simple logic, easy to understand and implement
-
Filtering short-term fluctuations by the consecutive days setting
-
Long only, less trades, lower transaction costs and slippage impact
-
Easy to set stop loss, effectively control single trade loss
Potential Risks
-
Unable to short tops, missing shorting opportunities
-
Need consecutive up days to enter, possibly missing best entry point
-
Time lag, not capturing turns in real time
-
Large single trade loss without stop loss
Summary
The consecutive up/down days strategy is widely popular for its simplicity and low frequency trading. With proper parameter tuning, it can filter out whipsaws effectively. But it also has limitations like time lag and inability to short. Investors need to consider carefully before adopting. Overall it suits investors seeking stable returns when tracking medium-long term trends.
/*backtest
start: 2023-08-12 00:00:00
end: 2023-09-11 00:00:00
period: 12h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
// Strategy
// strategy("Up/Down Long Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)- 1
