stock 30m 2022/07/16

mail@pastecode.io avatar
unknown
plain_text
2 years ago
7.6 kB
4
Indexable
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/


//@version=4
strategy(title= "stock strategy 30m",
         overlay=true,
         default_qty_type=strategy.percent_of_equity,
         default_qty_value=100,
         initial_capital=100000,
         commission_type=strategy.commission.percent,
         commission_value=0.17345)
   
   
//..............ENTER...SIGN...................

//momuntum sign 
t1 = input(50,"15")
t2 = security(syminfo.tickerid, "15", rsi(close,14))
t3 = crossover(t2,t1)
t4 = security(syminfo.tickerid, "15", rsi(close[6],14)>80 or rsi(close[7],14)>80 or rsi(close[8],14)>80 or rsi(close[9],14)>80) or rsi(close[10],14)>80 or rsi(close[11],14)>80 or rsi(close[12],14)>80 or rsi(close[13],14)>80 or rsi(close[14],14)>80 or rsi(close[15],14)>80 or rsi(close[16],14)>80 or rsi(close[17],14)>80 or rsi(close[18],14)>80 or rsi(close[19],14)>80 or rsi(close[20],14)>80 or rsi(close[21],14)>80 or rsi(close[22],14)>80 or rsi(close[23],14)>80 or rsi(close[24],14)>80 or rsi(close[25],14)>80 or rsi(close[26],14)>80 or rsi(close[27],14)>80 or rsi(close[28],14)>80 or rsi(close[29],14)>80 or rsi(close[30],14)>80 or rsi(close[31],14)>80 or rsi(close[32],14)>80 or rsi(close[33],14)>80 or rsi(close[34],14)>80 or rsi(close[35],14)>80 or rsi(close[36],14)>80 or rsi(close[37],14)>80 or rsi(close[38],14)>80 or rsi(close[39],14)>80 or rsi(close[40],14)>80 or rsi(close[41],14)>80 or rsi(close[42],14)>80 or rsi(close[43],14)>80 or rsi(close[42],14)>80 or rsi(close[44],14)>80 or rsi(close[45],14)>80 or rsi(close[46],14)>80 or rsi(close[47],14)>80 or rsi(close[48],14)>80 or rsi(close[49],14)>80 or rsi(close[50],14)>80 or rsi(close[51],14)>80 or rsi(close[52],14)>80 or rsi(close[53],14)>80 or rsi(close[54],14)>80 or rsi(close[55],14)>80 or rsi(close[56],14)>80 or rsi(close[57],14)>80 or rsi(close[58],14)>80 or rsi(close[59],14)>80 or rsi(close[60],14)>80 or rsi(close[61],14)>80 or rsi(close[62],14)>80 or rsi(close[63],14)>80 or rsi(close[64],14)>80 or rsi(close[65],14)>80 or rsi(close[66],14)>80 or rsi(close[67],14)>80 or rsi(close[68],14)>80 or rsi(close[69],14)>80 or rsi(close[70],14)>80 

t9 = security(syminfo.tickerid, "15", rsi(close[1],14)<50  or rsi(close[2],14)<50  or rsi(close[3],14)<50  or rsi(close[4],14)<50  or rsi(close[5],14)<50  or rsi(close[7],14)<50  or rsi(close[8],14)<50  or rsi(close[9],14)<50  or rsi(close[10],14)<50  or rsi(close[11],14)<50  or rsi(close[13],14)<50  or rsi(close[14],14)<50 )
t10 = security(syminfo.tickerid, "15", close>open)

//MA 
priceabovesma58= security(syminfo.tickerid, "15", sma(close[1],5)<sma(close,5)) //risk mangmenn
priceabovesma5 = security(syminfo.tickerid, "15", sma(close[3],50)<sma(close[1],50)) //risk mangmenn
priceabovesma52= security(syminfo.tickerid, "15", sma(close[1],21)<sma(close,21)) //risk mangmenn
priceabovesma53= security(syminfo.tickerid, "15", sma(close[2],21)<sma(close[1],21)) //risk mangmenn
priceabovesma51 = security(syminfo.tickerid, "15", sma(close[3],50)<sma(close[1],50)) //risk mangmenn
priceabovesma77= security(syminfo.tickerid, "5", sma(close,21)<sma(close,10))
priceabovesma50= security(syminfo.tickerid, "D", sma(close,50))
//rsi ma
as = security(syminfo.tickerid, "15", rsi(close,14))
ac = sma(as,14)
asac = as>ac

bb = security(syminfo.tickerid, "15", rsi(close,14))
kk = sma(bb,9)
bb1 = security(syminfo.tickerid, "15", rsi(close[1],14))
kk1 = sma(bb1,9)
bk = kk>kk1 //risk mangmenn

greencandel = security(syminfo.tickerid, "15", close > open)
//volume
vol =  security(syminfo.tickerid, "15", volume > sma(volume,50))
//rsi
bb4 = input(66,"D")
bb3 = security(syminfo.tickerid, "D", rsi(close,14))
kk3 = sma(bb3,5)
ff3 = kk3>bb4

t11 = security(syminfo.tickerid, "30", close > ema(close,65))
t12 = security(syminfo.tickerid, "30", rsi(close,14)>60)
t13 = security(syminfo.tickerid, "30", rsi(close,14)<70)
t16 = security(syminfo.tickerid, "D", rsi(close,14)>50)
// use exit
eee = security(syminfo.tickerid, "30", close < ema(low,26))

we3 = security(syminfo.tickerid, "30", ema(low,26))
we2 = security(syminfo.tickerid, "D", close<we3)

p10ma = security(syminfo.tickerid, "D", ema(close,10)>close)
p10mae = security(syminfo.tickerid, "D", ema(close,10)<close)

pma= security(syminfo.tickerid, "30", sma(close[1],10)>sma(close[2],10))

ttt = security(syminfo.tickerid, "30", sma(close,3)<sma(close,12)) 
rrr = security(syminfo.tickerid, "30", sma(close,3)>sma(close,12)) 
vvv = security(syminfo.tickerid, "30", close<ema(close,65)) 
we = security(syminfo.tickerid, "30", close>ema(close,50)) 
wew = security(syminfo.tickerid, "30", close>ema(high,21)) 


rsi70 = security(syminfo.tickerid, "15", rsi(close,14)<71)
rsi83 = security(syminfo.tickerid, "30", rsi(close,14)>80)
rsi55 = security(syminfo.tickerid, "D", rsi(close,14)>55)
rsi75d = security(syminfo.tickerid, "5", rsi(close,14)>66)
rsi80h = security(syminfo.tickerid, "1", rsi(close,14)>66)
rsi80f = security(syminfo.tickerid, "15", rsi(close,14)>75)

//(enter) new
volumeabovevolumesma50double6times1h = security(syminfo.tickerid, "30", volume > sma(volume,50)*6)
greencandel1h = security(syminfo.tickerid, "30", close > open)

priceabove10sma1d = security(syminfo.tickerid, "D", close<sma(close,10))

rsi1habove55 = security(syminfo.tickerid, "30", rsi(close,14)>55)

rsi1Dbetween30and65 = security(syminfo.tickerid, "D", rsi(close,14)>30 and rsi(close,14)<65)


asw = security(syminfo.tickerid, "D", rsi(close,14))
acw = security(syminfo.tickerid, "D", sma(asw,21))
asacw = asw>acw

xc1 = security(syminfo.tickerid, "D", rsi(close,14))
xc2 = security(syminfo.tickerid, "D", ema(xc1,10))
xc = xc1<xc2

w1 = security(syminfo.tickerid, "W", rsi(close,14))
w2 = security(syminfo.tickerid, "W", ema(w1,10))
wrsi = w1>w2

hhh2 = security(syminfo.tickerid, "W", rsi(close,14)>40)

p = security(syminfo.tickerid, "D", close>ema(close,26))

// back groud

bgcolor(color=   greencandel1h and priceabove10sma1d and rsi1habove55 and p and hhh2 ?color.red:na)
bgcolor(color=   t4 and priceabovesma5  and priceabovesma51 and priceabovesma52 and vol and bk and priceabovesma58 and priceabovesma53 and priceabovesma77  and rsi70 ?color.white:na)
bgcolor(color=  t3 and t4 and asac and priceabovesma5  and priceabovesma51 and priceabovesma52 and vol and bk and priceabovesma58 and priceabovesma53 and priceabovesma77 and  wew and we?color.blue:na)
//..............BUY............................nedd 
  
if 
     (priceabovesma50 and t16 and t3 and t4 and asac and priceabovesma5  and priceabovesma51 and priceabovesma52 and vol and bk and priceabovesma58 and priceabovesma53 and priceabovesma77 and asacw) 
     or (priceabovesma50 and t16 and rrr and t4  and t10 and t11 and t12 and asac and priceabovesma5  and priceabovesma51 and priceabovesma52 and vol and bk and priceabovesma58 and priceabovesma53 and priceabovesma77 and wew and we and asacw)
     or (  greencandel1h and priceabove10sma1d and rsi1habove55 and p and hhh2 and asacw )
    strategy.entry("Deal", true)

//..............TAKE PROFIT.........STOP LOSE.........

strategy.close(id="Deal", when= ( eee and we2 and p10ma and xc) )



///note
//اذا اجنمع rsi d < rsi ma21 + close previosly 2 day under ema low 26 this is sighn for exit 
//لكن هنا تكون اضعف  rsi d > rsi ma21 + close previosly 2 day under ema low 26 this is sighn for exit 
/// add to enter rsi > rsima12 in D and W time frame