I need help with translate code from tradingview Pine

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #64375 quote
    daniel123321
    Participant
    New

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

    #64380 quote
    Nicolas
    Keymaster
    Master

    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.

    daniel123321 thanked this post
    #64408 quote
    daniel123321
    Participant
    New

    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 quote
    daniel123321
    Participant
    New

    //@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”)

    anmoldavesar thanked this post
    #64670 quote
    Nicolas
    Keymaster
    Master

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

    #64746 quote
    daniel123321
    Participant
    New

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

    #64747 quote
    daniel123321
    Participant
    New

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

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    
    // Conditions pour ouvrir une position acheteuse
    indicator1 = LinearRegression[19](close)
    indicator2 = ExponentialAverage[224](close)-std[224](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    
    IF c1 THEN
    BUY 1 SHARES AT MARKET
    ENDIF
    
    // Conditions pour fermer une position acheteuse
    indicator3 = LinearRegression[19](close)
    indicator4 = ExponentialAverage[224](close)
    c2 = (indicator3 CROSSES OVER indicator4)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions pour ouvrir une position en vente à découvert
    indicator5 = LinearRegression[19](close)
    indicator6 = ExponentialAverage[224](close)+std[224](close)
    c3 = (indicator5 CROSSES UNDER indicator6)
    
    IF c3 THEN
    SELLSHORT 1 SHARES AT MARKET
    ENDIF
    
    // Conditions pour fermer une position en vente à découvert
    indicator7 = LinearRegression[19](close)
    indicator8 = ExponentialAverage[224](close)
    c4 = (indicator7 CROSSES UNDER indicator8)
    
    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF

     

    #64867 quote
    daniel123321
    Participant
    New

    4years backtest

    anmoldavesar thanked this post
    #90973 quote
    anmoldavesar
    Participant
    New

    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)
  • You must be logged in to reply to this topic.

I need help with translate code from tradingview Pine


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by anmoldavesar
7 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/04/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...