Open-strategy source
Strategy adjustment for particular exchange, pair and timeframe
Backtest
This crypto trading bot is using the Keltner strategy together with the trend based indicator and directional movement system. The stable profit that is achieved during the backtest is primarily linked with the combination of the accurate entry and the multiple take profits that can be easily set in Wunderbit Trading platform. This free TradingView bot can be easily automated at Wunderbit Trading using the TradingView strategy alerts. The detailed instruction and code is provided below.
IMPORTANT
This is a trend strategy and works better in the trending market
The strategy has the trend identifier using the EMA and SMA interaction
The strategy is using Multiple Take profit levels
Applicable to FTX: LINK/USDT 15 min
Input | Value |
Period | 43 |
Length | 81 |
Mult | 15 |
DI Length | 14 |
DMI Benchmark | 33 |
Long Take Profit 1% | 3.5 |
Long Take Profit 1 Qty | 15 |
Long Take Profy 2 % | 6.1 |
Long Take Profit 2 Qty | 100 |
Long Stop Loss % | 4 |
You can copy this code and paste it into your TradingView
//Original Idea by: Wunderbit Trading//Original Idea by: Wunderbit Trading//@version=4strategy("Keltner Channel ETH/USDT 1H", overlay=true, initial_capital=3000,pyramiding = 0, currency="USD", default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent,commission_value=0.1)/// TRENDribbon_period = input(43, "Period", step=1)leadLine1 = ema(close, ribbon_period)leadLine2 = sma(close, ribbon_period)// p3 = plot(leadLine1, color= #53b987, title="EMA", transp = 50, linewidth = 1)// p4 = plot(leadLine2, color= #eb4d5c, title="SMA", transp = 50, linewidth = 1)// fill(p3, p4, transp = 60, color = leadLine1 > leadLine2 ? #53b987 : #eb4d5c)//Upward TrendUT=leadLine2 < leadLine1DT=leadLine2>leadLine1///////////////////////////////////////INDICATORS// KELTNER //source = closeuseTrueRange = input(true)length = input(81, step=1, minval=1)mult = input(2.4, step=0.1)// Calculate Keltner Channelma = sma(source, length)range = useTrueRange ? tr : high - lowrangema = sma(range, length)upper = ma + rangema * multlower = ma - rangema * multplot(ma, title="Middle", color=color.orange)p1=plot(upper, title="Upper", color=color.orange)p2=plot(lower, title="Lower", color=color.orange)fill(p1,p2)// DMI INDICATOR //adxlen = 10 // input(10, title="ADX Smoothing")dilen = input(14, title="DI Length")keyLevel = 23// input(23, title="key level for ADX")dirmov(len) =>up = change(high)down = -change(low)truerange = rma(tr, len)plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)[plus, minus]adx(dilen, adxlen) =>[plus, minus] = dirmov(dilen)sum = plus + minusadx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)[adx, plus, minus][sig, up, down] = adx(dilen, adxlen)benchmark=input(title="DMI Benchmark", defval=33, minval=1,step=1)// plot(sig, color=color.red, title="ADX")// plot(up, style=plot.style_histogram, color=color.green, title="+DI")// plot(down, style=plot.style_histogram, color=color.red, title="-DI")// plot(keyLevel, color=color.white, title="Key Level")///////////////////////////////////////////////////////////////////////////////////////////////////////////////Component Code StarttestStartYear = input(2019, "Backtest Start Year")testStartMonth = input(1, "Backtest Start Month")testStartDay = input(1, "Backtest Start Day")testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)testStopYear = input(2020, "Backtest Stop Year")testStopMonth = input(12, "Backtest Stop Month")testStopDay = input(31, "Backtest Stop Day")testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)testPeriod() =>time >= testPeriodStart and time <= testPeriodStop ? true : false///// Component Code Stop ////////////////////////////////////////////////////////// STRATEGY EXECUTION ////////////////////////////LONG SET UP// Take Profit / Stop Losslong_tp1_inp = input(3.5, title='Long Take Profit 1 %', step=0.1)/100long_tp1_qty = input(15, title="Long Take Profit 1 Qty", step=1)long_tp2_inp = input(6.1, title='Long Take Profit 2%', step=0.1)/100long_tp2_qty = input(100, title="Long Take Profit 2 Qty", step=1)long_take_level_1 = strategy.position_avg_price * (1 + long_tp1_inp)long_take_level_2 = strategy.position_avg_price * (1 + long_tp2_inp)long_sl_inp = input(4, title='Long Stop Loss %', step=0.1)/100long_stop_level = strategy.position_avg_price * (1 - long_sl_inp)// STRATEGY CONDITION// LONGentry_long = ((open > lower and open < upper) and close > upper) and up > down and up > benchmark and volume[0] > volume[1]entry_price_long=valuewhen(entry_long,close,0)SL_long = entry_price_long * (1 - long_sl_inp)exit_long = (close < lower) or low < SL_long// STRATEGY EXECUTIONif testPeriod()// LONGif UTstrategy.entry(id="Long", long=true, when=entry_long, comment = "INSERT ENTRY LONG COMMAND")strategy.exit("TP1","Long", qty_percent=long_tp1_qty, limit=long_take_level_1) // PLACE TAKE PROFIT IN WBT BOT SETTINGSstrategy.exit("TP2","Long", qty_percent=long_tp2_qty, limit=long_take_level_2) // PLACE TAKE PROFIT IN WBT BOT SETTINGSstrategy.close(id="Long", when=exit_long, comment= "INSERT EXIT LONG COMMAND")//PLOT FIXED SLTP LINE// LONG POSITIONplot(strategy.position_size > 0 ? long_take_level_1 : na, style=plot.style_linebr, color=color.green, linewidth=1, title="1st Long Take Profit")plot(strategy.position_size > 0 ? long_take_level_2 : na, style=plot.style_linebr, color=color.green, linewidth=1, title="2nd Long Take Profit")plot(strategy.position_size > 0 ? long_stop_level : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Long Stop Loss")
Follow this guide to automate your TradingView STRATEGY alerts. (no need for study script).