Type/to search

Consecutive Up/Down N Days Strategy

Cryptocurrency
Created: 2023-09-12 11:51:10
Last modified: 3 years ago
1
Follow
1781
Followers

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

  1. Simple logic, easy to understand and implement

  2. Filtering short-term fluctuations by the consecutive days setting

  3. Long only, less trades, lower transaction costs and slippage impact

  4. Easy to set stop loss, effectively control single trade loss

Potential Risks

  1. Unable to short tops, missing shorting opportunities

  2. Need consecutive up days to enter, possibly missing best entry point

  3. Time lag, not capturing turns in real time

  4. 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.

Source
Pine
/*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)
Strategy parameters
Strategy parameters
consecutiveBarsUp
consecutiveBarsDown
startDate
finishDate
Buy message
Sell message
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)