
Chiến lược này là chiến lược kết hợp dựa trên hai chỉ số EMA và chỉ số Bull Power. Tên của chiến lược bao gồm các từ khóa “Hydrogen Citrate and Hydrogen Dioxide”, làm nổi bật tính năng sử dụng hai chỉ số độc lập.
Chiến lược này bao gồm hai phần:
Hai phần của tín hiệu cần được kích hoạt cùng một lúc để mở vị trí. Ví dụ: EMA Gold Fork và Bull Power đồng thuận để mở nhiều vị trí, EMA Dead Fork và Bull Power đồng thuận để mở vị trí trống.
Chiến lược này thực hiện các quyết định giao dịch thông qua việc sử dụng kết hợp hai EMA và Bull Power. So với chỉ số đơn lẻ, chỉ số kết hợp có thể lọc hiệu quả các tín hiệu giả, trong khi vẫn duy trì chất lượng tín hiệu giao dịch và có thể điều chỉnh các tham số. Nhìn chung, chiến lược này đơn giản, dễ hiểu và linh hoạt trong thực tế, là một chiến lược giao dịch định lượng có tính thực tế mạnh mẽ.
/*backtest
start: 2022-12-22 00:00:00
end: 2023-12-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 12/07/2022
// This is combo strategies for get a cumulative signal.
//
// First strategy
// This indicator plots 2/20 exponential moving average. For the Mov
// Avg X 2/20 Indicator, the EMA bar will be painted when the Alert criteria is met.
//
// Second strategy
// Bull Power Indicator
// To get more information please see "Bull And Bear Balance Indicator"
// by Vadim Gimelfarb.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
EMA20(Length) =>
pos = 0.0
xPrice = close
xXA = ta.ema(xPrice, Length)
nHH = math.max(high, high[1])
nLL = math.min(low, low[1])
nXS = nLL > xXA or nHH < xXA ? nLL : nHH
iff_1 = nXS < close[1] ? 1 : nz(pos[1], 0)
pos := nXS > close[1] ? -1 : iff_1
pos
BP(SellLevel) =>
pos = 0.0
value = close < open ?
close[1] < open ? math.max(high - close[1], close - low): math.max(high - open, close - low):
close > open ?
close[1] > open ? high - low : math.max(open - close[1], high - low) :
high - close > close - low ?
close[1] < open ? math.max(high - close[1], close - low) : high - open :
high - close < close - low ?
close[1] > open ? high - low : math.max(open - close, high - low) :
close[1] > open ? math.max(high - open, close - low) :
close[1] < open? math.max(open - close, high - low): high - low
val2 = ta.sma(value, 15)
pos := val2 > SellLevel ? 1 : -1
pos
strategy(title='Combo 2/20 EMA & Bull Power', shorttitle='Combo', overlay=true)
var I1 = '●═════ 2/20 EMA ═════●'
Length = input.int(14, minval=1, group=I1)
var I2 = '●═════ Bull Power ═════●'
SellLevel = input.float(-15, step=0.01, group=I2)
var misc = '●═════ MISC ═════●'
reverse = input.bool(false, title='Trade reverse', group=misc)
var timePeriodHeader = '●═════ Time Start ═════●'
d = input.int(1, title='From Day', minval=1, maxval=31, group=timePeriodHeader)
m = input.int(1, title='From Month', minval=1, maxval=12, group=timePeriodHeader)
y = input.int(2005, title='From Year', minval=0, group=timePeriodHeader)
StartTrade = time > timestamp(y, m, d, 00, 00) ? true : false
posEMA20 = EMA20(Length)
prePosBP = BP(SellLevel)
iff_1 = posEMA20 == -1 and prePosBP == -1 and StartTrade ? -1 : 0
pos = posEMA20 == 1 and prePosBP == 1 and StartTrade ? 1 : iff_1
iff_2 = reverse and pos == -1 ? 1 : pos
possig = reverse and pos == 1 ? -1 : iff_2
if possig == 1
strategy.entry('Long', strategy.long)
if possig == -1
strategy.entry('Short', strategy.short)
if possig == 0
strategy.close_all()
barcolor(possig == -1 ? #b50404 : possig == 1 ? #079605 : #0536b3)