I need help with translate code from tradingview Pine

Forums ProRealTime English forum ProOrder support I need help with translate code from tradingview Pine

Viewing 9 posts - 1 through 9 (of 9 total)
  • #64375

    Can somebody translate code from Pine to PRT, It’s a strategy code not that long.

    #64380

    Topic moved to ProOrder support forum since it’s related to automatic trading. Please post the code here and I’ll have a look later, thank you.

    1 user thanked author for this post.
    #64408

    One last question does the PRT backtest with hirstorical spread info, because TV only can add commission.. ?

     

    //@version=3
    strategy(shorttitle=”CTO stratrgy RISKLEVEL=1/2/3 (XAUUSD 4h Settings)RSI/FILTER”, title=”CTO”, overlay=true)

    //////RSI
    RSIlength = input(2,title=”RSI Period Length”)
    //we need oversold rsi cuz its better performing
    RSIoverSold = 50
    RSIoverBought40 = 40
    RSIoverBought50 = 50
    price = close
    vrsi = rsi(price, RSIlength)

    //////BBands
    src = input(ohlc4, title = “source”)
    len = input(224, title = “timeframe/# of periods”)
    e = ema(src,len)
    evar = (src – e)*(src – e)
    evar2 = (sum(evar,len))/len
    std = sqrt(evar2)
    Multiplier = input(1, minval = 0.01, title = “Multiplier”)
    upper = e + (Multiplier * std)
    lower = e – (Multiplier * std)
    //
    plot(e, color = aqua, linewidth = 1, title = “AQUA”)

    p1 = plot(upper, color=green)
    p2 = plot(lower, color=red)
    fill(p1, p2 ,purple)

    //STRATEGY with SL and TP-at opposite band not aqua tp
    //FILTER BUY
    length = input(title=”LSMABUYLength”, type=integer, defval=19)
    offset = input(title=”LSMASELLOffset”, type=integer, defval=0)
    src1 = input(close, title=”LSMA-BUYSource”)
    lsma = linreg(src1, length, offset)
    plot(lsma)

    //CONDITIONS
    source = lsma

    //MAP
    buyEntry = crossover(source, lower)
    sellEntry = crossunder(source, upper)
    takeProfitbuy = crossunder(source, e)

    //Strategy RR3

    //LONG ENTRY
    if crossover(source, lower)
    strategy.entry(“LE”, strategy.long, oca_type=strategy.oca.cancel, stop=lower, oca_name=”CTO”, comment=”LE”)
    //LONG S/L
    if (crossunder(source, lower))
    strategy.close(id=”LE”)
    //TAKE PROF LONG
    if (cross(source, e) and cross(vrsi, RSIoverSold)) or crossunder(source, upper)
    strategy.close(id=”LE”)

    //SHORT ENTRY
    if crossunder(source, upper)
    strategy.entry(“SE”, strategy.short, oca_type=strategy.oca.cancel, stop=upper, oca_name=”SE”, comment=”SE”)
    else
    strategy.cancel(id=”SE”)
    //SHORT S/L
    if (crossover(source, upper) and crossunder(vrsi, RSIoverBought50)) or (crossover(source,upper) and crossunder(vrsi,RSIoverBought40))
    strategy.close(id=”SE”)
    //TAKE PROF SHORT
    if (cross(source, e) and crossover(vrsi, RSIoverBought50)) or cross(source, lower)
    strategy.close(id=”SE”)
    //last idea buy tp fix

     

    //Strategy RR2

    //LONG ENTRY
    if crossover(source, lower)
    strategy.entry(“LE”, strategy.long, oca_type=strategy.oca.cancel, stop=lower, oca_name=”CTO”, comment=”LE”)
    //LONG S/L
    if (crossunder(source, lower))
    strategy.close(id=”LE”)
    //TAKE PROF LONG
    if (cross(source, e) and cross(vrsi, RSIoverSold)) or crossunder(source, upper)
    strategy.close(id=”LE”)

    //SHORT ENTRY
    if crossunder(source, upper)
    strategy.entry(“SE”, strategy.short, oca_type=strategy.oca.cancel, stop=upper, oca_name=”SE”, comment=”SE”)
    else
    strategy.cancel(id=”SE”)
    //SHORT S/L
    if (crossover(source, upper) and (vrsi < 50 ))
    strategy.close(id=”SE”)
    //TAKE PROF SHORT
    if (cross(source, e) and crossover(vrsi, 50 )) or cross(source, lower) or crossover(source, e)
    strategy.close(id=”SE”)

     

    //Strategy RR1

    //LONG ENTRY
    if crossover(source, lower)
    strategy.entry(“LE”, strategy.long, oca_type=strategy.oca.cancel, stop=lower, oca_name=”CTO”, comment=”LE”)
    //LONG S/L
    if (crossunder(source, lower))
    strategy.close(id=”LE”)
    //TAKE PROF LONG
    if (cross(source, e) and cross(vrsi, RSIoverSold)) or crossunder(source, upper)
    strategy.close(id=”LE”)

    //SHORT ENTRY
    if crossunder(source, upper) and (vrsi > 15)
    strategy.entry(“SE”, strategy.short, oca_type=strategy.oca.cancel, stop=upper, oca_name=”SE”, comment=”SE”)
    else
    strategy.cancel(id=”SE”)
    //SHORT S/L
    if crossover(source, upper)
    strategy.close(id=”SE”)
    //TAKE PROF SHORT
    if (cross(source, e) and crossover(vrsi, RSIoverBought50)) or cross(source, lower)
    strategy.close(id=”SE”)

    #64427

    //@version=3
    strategy(shorttitle=”CTO stratrgy RISKLEVEL=4 (XAUUSD 4h Settings)DB/RSI/FILTER”, title=”CTO”, overlay=true)

    //////RSI
    RSIlength = input(2,title=”RSI Period Length”)
    //we need oversold rsi cuz its better performing
    RSIoverSold = 50
    RSIoverBought40 = 40
    RSIoverBought50 = 50
    price = close
    vrsi = rsi(price, RSIlength)

    //////BBands
    src = input(ohlc4, title = “source”)
    len = input(224, title = “timeframe/# of periods”)
    e = ema(src,len)
    evar = (src – e)*(src – e)
    evar2 = (sum(evar,len))/len
    std = sqrt(evar2)
    Multiplier = input(1, minval = 0.01, title = “Multiplier”)
    upper = e + (Multiplier * std)
    lower = e – (Multiplier * std)
    //
    plot(e, color = aqua, linewidth = 1, title = “AQUA”)

    p1 = plot(upper, color=green)
    p2 = plot(lower, color=red)
    fill(p1, p2 ,purple)

    //
    //////Detrend Breakout
    lengthdb = input(50),mult = input(2),vol = input(20)
    d = close – rma(close,lengthdb)
    cos = (cum(abs(d))/n) * mult
    upperdb = 0 + cos
    lowerdb = 0 – cos

    //STRATEGY with SL and TP-at opposite band not aqua tp
    //FILTER BUY
    length = input(title=”LSMABUYLength”, type=integer, defval=19)
    offset = input(title=”LSMASELLOffset”, type=integer, defval=0)
    src1 = input(close, title=”LSMA-BUYSource”)
    lsma = linreg(src1, length, offset)
    plot(lsma)

    //CONDITIONS
    source = lsma

    //MAP
    buyEntry = crossover(source,lower)
    sellEntry = crossunder(d,upper)
    takeProfitbuy = cross(source,e)
    takeProfitsell = crossunder(source,e)
    t = volume > sma(volume,vol)

    //LONG ENTRY
    if crossover(source, lower)
    strategy.entry(“LE”, strategy.long, oca_type=strategy.oca.cancel, stop=lower, oca_name=”CTO”, comment=”LE”)
    //LONG S/L
    if (crossunder(source, lower))
    strategy.close(id=”LE”)
    //TAKE PROF LONG
    if (cross(source, e) and cross(vrsi, RSIoverSold)) or crossunder(source, upper)
    strategy.close(id=”LE”)

    //SHORT ENTRY
    if crossunder(d,31) and t
    strategy.entry(“SE”, strategy.short, oca_type=strategy.oca.cancel, comment=”SE”)
    //SHORT S/L
    if (crossover(source, upper) and crossunder(vrsi, RSIoverBought50)) or (crossover(source,upper) and crossunder(vrsi,RSIoverBought40))
    strategy.close(id=”SE”)
    //TAKE PROF SHORT
    if cross(source, e)
    strategy.close(id=”SE”)

    1 user thanked author for this post.
    #64670

    Sorry but what is the good strategy to translate? The one from your last post?

    #64746

    Last one yes. Its preforming better than RR 1/2 and 3.

    #64747

    I have the base code of BB + LSMA for prt but I need to insert more right conditions like DB and RSI.

     

     

    #64867

    4years backtest

    1 user thanked author for this post.
    #90973

    Can you please mail me this script.. or paste it here.. i am not able to copy properly to work on it. Thanks

Viewing 9 posts - 1 through 9 (of 9 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login