pinescript strategy to cbot

20 EUR  Payment method:  Direct Payment

i want convert this strategy in pine script to cbot 

strategy(title="Optimized Keltner Channels SL/TP Strategy for BTC", overlay=true)
length = input(4, minval=1)
mult = input(1.0, "Multiplier")
src = input(close, title="Source")
exp = input(true, "Use Exponential MA")
BandsStyle = input("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style")
atrlength = input(1, "ATR Length")
sl = input(defval=20, minval=0, type=input.float, step=0.1, title="Stop Loss (%)")
tp = input(defval=20.3, minval=0, type=input.float, step=0.1, title="Take Profit (%)")

esma(source, length)=>
    s = sma(source, length)
    e = ema(source, length)
    exp ? e : s
ma = esma(src, length)
rangema = BandsStyle == "True Range" ? rma(tr(true), length) : BandsStyle == "Average True Range" ? atr(atrlength) : rma(high - low, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
c =
u = plot(upper,, title="Upper")
plot(ma, color=#0094FF, title="Basis")
l = plot(lower,, title="Lower")
fill(u, l,, transp=95), title="Background")
crossUpper = crossover(src, upper)
crossLower = crossunder(src, lower)
bprice = 0.0
bprice := crossUpper ? close+syminfo.mintick : nz(bprice[1])
sprice = 0.0
sprice := crossLower ? close-syminfo.mintick : nz(sprice[1])
crossBcond = false
crossBcond := crossUpper ? true
     : na(crossBcond[1]) ? false : crossBcond[1]
crossScond = false
crossScond := crossLower ? true
     : na(crossScond[1]) ? false : crossScond[1]
cancelBcond = crossBcond and (src < ma or high >= bprice )
cancelScond = crossScond and (src > ma or low <= sprice )
testStartYear = input(2018, "Backtest Start Year", minval=1980)
testStartMonth = input(1, "Backtest Start Month", minval=1, maxval=12)
testStartDay = input(1, "Backtest Start Day", minval=1, maxval=31)
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)

testStopYear = input(9999, "Backtest Stop Year", minval=1980)
testStopMonth = input(12, "Backtest Stop Month", minval=1, maxval=12)
testStopDay = input(31, "Backtest Stop Day", minval=1, maxval=31)
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)

testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false

if  testPeriod()and(cancelBcond)
if testPeriod()and(crossUpper) 
    strategy.entry("KltChLE", strategy.long, stop=bprice, comment="Long")

if testPeriod()and(cancelScond)
if testPeriod()and(crossLower)
    strategy.entry("KltChSE", strategy.short, stop=sprice, comment="Short")

strategy.exit("Long exit", "KltChLE", profit = close * tp * 0.01 / syminfo.mintick, loss = close * sl * 0.01 / syminfo.mintick)
strategy.exit("Short exit", "KltChSE", profit = close * tp * 0.01 / syminfo.mintick, loss = close * sl * 0.01 / syminfo.mintick)


Hi there,

We can help you with your project. You can contact us at for more information.

Best Regards,


My name is Mike from 4xdev. I am a member of the 4xdev development company, specialized in creating trading tools:
custom indicators, EAs, scripts, bots, alerts, cAlgo, cBots, etc.

We have a great experience in a —ĀTrader platform.
Our clients are satisfied with the quality of our work and repeatedly contact us after completing an order to optimize their own cAlgos.
You can see reviews of us at and, and our website

We can help you with your project. Please let me know if you are interested:

We offer the rate in the amount of $60 per hour, including the work of our programmers and QA-engineer.
The cost starts from $300 on average.

Looking forward to hearing from you.

I'm a freelancer and can write any code you want
If you can explain what your code does, I can write it