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