pinescript strategy to cbot

Created at 10 Jan 2022
SA

sajad.nazari.1996

Joined 10.01.2022

Status

Open


Budget

20.00 EUR


Payment Method

Direct Payment

Job Description

i want convert this strategy in pine script to cbot 

//@version=4
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 = color.blue
u = plot(upper, color=color.green, title="Upper")
plot(ma, color=#0094FF, title="Basis")
l = plot(lower, color=color.red, title="Lower")
fill(u, l, color.new(color=#0094FF, 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)
    strategy.cancel("KltChLE") 
if testPeriod()and(crossUpper) 
    strategy.entry("KltChLE", strategy.long, stop=bprice, comment="Long")

if testPeriod()and(cancelScond)
    strategy.cancel("KltChSE")
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)

plot(bprice, color=color.green)
plot(sprice, color=color.red)

Comments
Log in to add a comment.
AlgoCreators's avatar
AlgoCreators · 2 years ago

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

4xdev.team's avatar
4xdev.team · 2 years ago

Hello!
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 forexpeacearmy.com and trustpilot.com, and our website 4xdev.com.

We can help you with your project. Please let me know if you are interested: support@4xdev.com

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.

DonaldD's avatar
DonaldD · 2 years ago

Hi there,

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

Best Regards,

Donald