0% found this document useful (0 votes)
54 views2 pages

New Proga

Uploaded by

vemula.sravani99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views2 pages

New Proga

Uploaded by

vemula.sravani99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//@version=5

strategy(title="Proga all", overlay = true, calc_on_order_fills = true,


calc_on_every_tick = true)
Length = 5
select = 1
stoploss = input(true, "fr hiken")
SLL = input(false, "Stop loss")
TPT = input(false, "take profit")
TP = input(defval = 2, title = "Take profit")
x = input(defval = 2, title = "SL")
xSMA = select == 1 ? ta.sma(close, Length) : ta.ema(close, Length)
xHighBand = select == 1 ? ta.sma(high, Length) : ta.ema(high, Length)
xLowBand = select == 1 ? ta.sma(low, Length) : ta.ema(low, Length)

// ztrend setup
p=2
fastend = 0.795
slowend = 0.0645
kama(close,amaLength)=>
kama = float(na)
diff=math.abs(close[0]-close[1])
signal=math.abs(close-close[amaLength])
noise=math.sum(diff, amaLength)
efratio=noise!=0 ? signal/noise : 1
smooth=math.pow(efratio*(fastend-slowend)+slowend,2)
kama:=nz(kama[1], close)+smooth*(close-nz(kama[1], close))
kama

hakamaper=1
Signal=input(true)
Om=ta.ema(open,p)
Hm=ta.ema(high,p)
Lm=ta.ema(low,p)
Cm=ta.ema(close,p)
vClose=(Om+Hm+Lm+Cm)/4
vOpen= kama(vClose[1],hakamaper)
vHigh= math.max(Hm,math.max(vClose, vOpen))
vLow= math.min(Lm,math.min(vClose, vOpen))

// === Time FUNCTION ===


//backtest range
FromMonth = input(defval = 1, title = "From Month")
FromDay = input(defval = 1, title = "From Day")
FromYear = input(defval = 2017, title = "From Year")
ToMonth = input(defval = 1, title = "To Month")
ToDay = input(defval = 1, title = "To Day")
ToYear = input(defval = 9999, title = "To Year")
start = timestamp(FromYear, FromMonth, FromDay, 00, 00)
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)
window() => time >= start and time <= finish ? true : false

//Alert
//code = input.string("", title = "Code")
inputbuy = input.text_area("Buy", title = "Input Long")
inputsell = input.text_area("Sell", title = "Input Short")
pos = float(na)
pos := close > xHighBand ? 1 : close <xLowBand ? -1 : nz(pos[1], 0)

if (pos == 1 and vOpen<vClose)


strategy.entry("Long", strategy.long, when = window() and pos == 1,
stop=(stoploss ? high+syminfo.mintick : na), alert_message = inputbuy)

if (pos == -1 and vOpen>vClose)


strategy.entry("Short", strategy.short, when = window() and pos == -
1,stop=(stoploss ? low-syminfo.mintick : na), alert_message = inputsell)

// === STRATEGY - POSITION EXECUTION ===


if (TPT and strategy.position_size > 75)
strategy.exit("exit", "Long", 75, profit = TP*100)
if (strategy.position_size < -75 and TPT)
strategy.exit("exit", "Short", 75, profit = TP*100)

if (SLL and strategy.position_size > 75)


strategy.exit("exit", "Long",75, loss = x*100)
if (strategy.position_size < -75 and SLL)
strategy.exit("exit", "Short",75, loss = x*100)

// === PLOTTING ===


plotchar(pos == 1 and vOpen<vClose, char='❄',color=color.green)
plotchar(pos == -1 and vOpen>vClose, char='❄',color=color.red)
bgcolor(pos == -1 and vOpen>vClose? color.rgb(255, 82, 82, 79): pos ==1 and
vOpen<vClose?color.rgb(76, 175, 79, 88):na)

You might also like