This week we decided to start with the 15 min CCI strategy from the user: faresg7900
TradingView Bot strategy is based on TSI CCI Hull.
IMPORTANT
This is a trend strategy and works better in the uptrend
This strategy doe not have a stop-loss so your drawdown in the position can be large
This strategy is only working for long positions
This strategy take-profit will be triggered only if the price will “close” above 0.5% of the entry price. Therefore, you do not need to set a take-profit target in the Wunderbit Trading cabinet.
Applicable to: BTC-PERP 15min
Settings
Variable | Value |
Long Length | 41 |
Short Length | 43 |
Signal Length | 21 |
Source | CLOSE |
Period | 26 |
Upper Line Line | 100 |
Lower Line | -100 |
LongProfitPercent | 0.5 |
ShortProfitPercent | 0.5 |
Profit Long Source | CLOSE |
Profit Short Source | CLOSE |
Revised TradingView strategy script code
You can copy this code and paste it into your TradingView.
//@version=5
strategy(title='TSI CCI Hull', shorttitle='TSICCIHULL', default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_order_fills=false, calc_on_every_tick=true, pyramiding=0, commission_type=strategy.commission.percent, commission_value=0.07)
long = input(title='Long Length', defval=41)
short = input(title='Short Length', defval=43)
signal = input(title='Signal Length', defval=21)
price = input(title='Source', defval=close)
Period = input.int(26, minval=1)
lineupper = input(title='Upper Line', defval=100)
linelower = input(title='Lower Line', defval=-100)
p = price
length = Period
double_smooth(src, long, short) =>
fist_smooth = ta.ema(src, long)
ta.ema(fist_smooth, short)
pc = ta.change(price)
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(math.abs(pc), long, short)
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
keh = tsi_value * 5 > linelower ? color.red : color.lime
teh = ta.ema(tsi_value * 5, signal * 5) > lineupper ? color.red : color.lime
meh = ta.ema(tsi_value * 5, signal * 5) > tsi_value * 5 ? color.red : color.lime
i1 = plot(tsi_value * 5, title='TSI Value', color=color.new(color.black, 100), linewidth=1)
i2 = plot(ta.ema(tsi_value * 5, signal * 5), title='TSI Signal', color=color.new(color.black, 100), linewidth=1)
fill(i1, i2, color=meh, transp=85)
plot(ta.cross(tsi_value * 5, ta.ema(tsi_value * 5, signal * 5)) ? tsi_value * 5 : na, style=plot.style_circles, color=color.new(color.black, 0), linewidth=10)
plot(ta.cross(tsi_value * 5, ta.ema(tsi_value * 5, signal * 5)) ? tsi_value * 5 : na, style=plot.style_circles, color=color.new(color.white, 0), linewidth=8)
plot(ta.cross(tsi_value * 5, ta.ema(tsi_value * 5, signal * 5)) ? tsi_value * 5 : na, style=plot.style_circles, color=meh, linewidth=5)
n2ma = 2 * ta.wma(p, math.round(length / 2))
nma = ta.wma(p, length)
diff = n2ma - nma
sqn = math.round(math.sqrt(length))
n1 = ta.wma(diff, sqn)
cci = (p - n1) / (0.015 * ta.dev(p, length))
c = cci > 0 ? color.lime : color.red
c1 = cci > 20 ? color.lime : color.silver
c2 = cci < -20 ? color.red : color.silver
cc = plot(cci, color=c, title='CCI Line', linewidth=2)
cc2 = plot(cci[1], color=color.new(color.gray, 100), linewidth=1)
fill(cc, cc2, color=c, transp=85)
plot(ta.cross(20, cci) ? 20 : na, style=plot.style_cross, title='CCI cross UP', color=c1, linewidth=2, offset=-2, transp=100)
plot(ta.cross(-20, cci) ? -20 : na, style=plot.style_cross, title='CCI cross down', color=c2, linewidth=2, offset=-2, transp=100)
TSI1 = ta.ema(tsi_value * 5, signal * 5)
TSI2 = ta.ema(tsi_value * 5, signal * 5)[2]
hullma_smoothed = ta.wma(2 * ta.wma(n1, Period / 2) - ta.wma(n1, Period), math.round(math.sqrt(Period)))
//plot(hullma_smoothed*200)
// Make input options that configure backtest date range
startDate = input.int(title='Start Date', defval=1, minval=1, maxval=31)
startMonth = input.int(title='Start Month', defval=1, minval=1, maxval=12)
startYear = input.int(title='Start Year', defval=2018, minval=1800, maxval=2100)
endDate = input.int(title='End Date', defval=1, minval=1, maxval=31)
endMonth = input.int(title='End Month', defval=7, minval=1, maxval=12)
endYear = input.int(title='End Year', defval=2099, minval=1800, maxval=2100)
// Look if the close time of the current bar
// falls inside the date range
inDateRange = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0)
LongProfitPercent = input.float(0.5, step=0.1)
ShortProfitPercent = input.float(0.5, step=0.1)
LP = LongProfitPercent / 100 + 1
SP = ShortProfitPercent / 100 + 1
LongProfitSource = input(title='profit long source', defval=close)
ShortProfitSource = input(title='profit short source', defval=close)
longCondition = TSI1 > TSI2 and hullma_smoothed < price and cci > 0
shortCondition = TSI1 < TSI2 and hullma_smoothed > price and cci < 0
if longCondition and cci > cci[1] and cci > 0 and n1 > n1[1] and inDateRange
strategy.entry('buy', strategy.long)
strategy.close('buy', when=shortCondition and cci < cci[1] and cci < 0 and n1 < n1[1] or LongProfitSource > strategy.position_avg_price * LP and inDateRange)
// if (shortCondition and cci<cci[1] and cci < 0 and n1<n1[1] and inDateRange)
// strategy.entry("sell", strategy.short)
// strategy.close("sell", when = longCondition and cci>cci[1] and cci > 0 and n1>n1[1] or ShortProfitSource<strategy.position_avg_price/SP and inDateRange)