I need help with translate code from tradingview Pine
Forums › ProRealTime English forum › ProOrder support › I need help with translate code from tradingview Pine
- This topic has 8 replies, 3 voices, and was last updated 5 years ago by anmoldavesar.
-
-
03/04/2018 at 11:50 PM #64375
Can somebody translate code from Pine to PRT, It’s a strategy code not that long.
03/05/2018 at 8:14 AM #64380Topic 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.
03/05/2018 at 10:41 AM #64408One 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”)03/05/2018 at 12:11 PM #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.
03/07/2018 at 2:13 PM #6467003/08/2018 at 9:55 AM #64746Last one yes. Its preforming better than RR 1/2 and 3.
03/08/2018 at 9:56 AM #64747I have the base code of BB + LSMA for prt but I need to insert more right conditions like DB and RSI.
1234567891011121314151617181920212223242526272829303132333435363738// Définition des paramètres du codeDEFPARAM CumulateOrders = False // Cumul des positions désactivé// Conditions pour ouvrir une position acheteuseindicator1 = LinearRegression[19](close)indicator2 = ExponentialAverage[224](close)-std[224](close)c1 = (indicator1 CROSSES OVER indicator2)IF c1 THENBUY 1 SHARES AT MARKETENDIF// Conditions pour fermer une position acheteuseindicator3 = LinearRegression[19](close)indicator4 = ExponentialAverage[224](close)c2 = (indicator3 CROSSES OVER indicator4)IF c2 THENSELL AT MARKETENDIF// Conditions pour ouvrir une position en vente à découvertindicator5 = LinearRegression[19](close)indicator6 = ExponentialAverage[224](close)+std[224](close)c3 = (indicator5 CROSSES UNDER indicator6)IF c3 THENSELLSHORT 1 SHARES AT MARKETENDIF// Conditions pour fermer une position en vente à découvertindicator7 = LinearRegression[19](close)indicator8 = ExponentialAverage[224](close)c4 = (indicator7 CROSSES UNDER indicator8)IF c4 THENEXITSHORT AT MARKETENDIF03/09/2018 at 12:37 AM #648674years backtest
1 user thanked author for this post.
02/10/2019 at 1:05 PM #90973Can you please mail me this script.. or paste it here.. i am not able to copy properly to work on it. Thanks
-
AuthorPosts
Find exclusive trading pro-tools on