Buy or sell candle patterns below or above MA
EMA_for_1D-EMA to use for 1D chart
Period_- highest/lowest days to put SL
Mercurius.a.m
Mercurius.a.m@gmail.com
EMA_for_1D-EMA to use for 1D chart
Period_- highest/lowest days to put SL
Mercurius.a.m
Mercurius.a.m@gmail.com
//@version=2 strategy("engulfing", pyramiding=40, initial_capital=20000) //модуль тела свечи body=abs(open-close) //цвет свечи: красная или зеленая colour=open>close //взвешенная сс period_ema_for_1D=input(defval=22,title="ema_for_1D",type=integer, minval=1, maxval=500, step=5) ema_1DD=ema(close, period_ema_for_1D) ema_1D=ema(close,5) tp_sl_ratio=input(defval=2,title="tp_sl_ratio",type=integer, minval=1, maxval=10, step=1) //верхняя тень up_shadow=abs(high-close) //бычья сила бычей свечи from_down_power=abs(low-close) //нижняя тень down_shadow=abs(low-close) //медвежья сила медвежей свечи from_up_power=abs(high-close) //процент от тела body_percent=(body[0]/body[1])*100 //перекрытия x1=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]>open[1] and colour[0]==false and colour[1]==true and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and isdwm and close>ema_1DD and dayofweek==1) x2=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]>open[1] and colour[0]==false and colour[1]==true and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and isdwm and close>ema_1DD and dayofweek==2) x3=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]>open[1] and colour[0]==false and colour[1]==true and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and isdwm and close>ema_1DD and dayofweek==3) x4=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]>open[1] and colour[0]==false and colour[1]==true and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and isdwm and close>ema_1DD and dayofweek==4) x5=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]>open[1] and colour[0]==false and colour[1]==true and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and isdwm and close>ema_1DD and dayofweek==5) y1=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]<open[1] and colour[0]==true and colour[1]==false and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and isdwm and close<ema_1DD and dayofweek==1) y2=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]<open[1] and colour[0]==true and colour[1]==false and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and isdwm and close<ema_1DD and dayofweek==2) y3=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]<open[1] and colour[0]==true and colour[1]==false and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and isdwm and close<ema_1DD and dayofweek==3) y4=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]<open[1] and colour[0]==true and colour[1]==false and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and isdwm and close<ema_1DD and dayofweek==4) y5=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]<open[1] and colour[0]==true and colour[1]==false and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and isdwm and close<ema_1DD and dayofweek==5) //проникновения r1=close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and open[0]<close[1] and body_percent>50 and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and close>ema_1DD and dayofweek==1 r2=close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and open[0]<close[1] and body_percent>50 and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and close>ema_1DD and dayofweek==2 r3=close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and open[0]<close[1] and body_percent>50 and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and close>ema_1DD and dayofweek==3 r4=close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and open[0]<close[1] and body_percent>50 and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and close>ema_1DD and dayofweek==4 r5=close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and open[0]<close[1] and body_percent>50 and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and close>ema_1DD and dayofweek==5 t1=close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and open[0]>close[1] and body_percent>50 and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and close<ema_1DD and dayofweek==1 t2=close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and open[0]>close[1] and body_percent>50 and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and close<ema_1DD and dayofweek==2 t3=close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and open[0]>close[1] and body_percent>50 and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and close<ema_1DD and dayofweek==3 t4=close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and open[0]>close[1] and body_percent>50 and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and close<ema_1DD and dayofweek==4 t5=close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and open[0]>close[1] and body_percent>50 and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and close<ema_1DD and dayofweek==5 //h90 h1=body_percent>50 and close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and open[0]<ema(close,5)[0] and close>ema_1DD and dayofweek==1 h2=body_percent>50 and close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and open[0]<ema(close,5)[0] and close>ema_1DD and dayofweek==2 h3=body_percent>50 and close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and open[0]<ema(close,5)[0] and close>ema_1DD and dayofweek==3 h4=body_percent>50 and close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and open[0]<ema(close,5)[0] and close>ema_1DD and dayofweek==4 h5=body_percent>50 and close[0]>close[1] and colour[0]==false and colour[1]==true and isdwm and close[0]<open[1] and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and open[0]<ema(close,5)[0] and close>ema_1DD and dayofweek==5 g1=body_percent>50 and close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and open[0]>ema(close,5)[0] and close<ema_1DD and dayofweek==1 g2=body_percent>50 and close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and open[0]>ema(close,5)[0] and close<ema_1DD and dayofweek==2 g3=body_percent>50 and close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and open[0]>ema(close,5)[0] and close<ema_1DD and dayofweek==3 g4=body_percent>50 and close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and open[0]>ema(close,5)[0] and close<ema_1DD and dayofweek==4 g5=body_percent>50 and close[0]<close[1] and colour[0]==true and colour[1]==false and isdwm and close[0]>open[1] and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and open[0]>ema(close,5)[0] and close<ema_1DD and dayofweek==5 period_=input(defval=1,title="period_",type=integer, minval=1, maxval=100, step=1) buy_qty=(100/(((close[0]-lowest(low,period_))*100000)))*100000 stop_buy=lowest(low, period_) profit_buy=((close-stop_buy)*tp_sl_ratio)+close if x1==true strategy.order("buy1", strategy.long, qty=buy_qty) strategy.exit("close1", from_entry="buy1", stop=stop_buy, limit=profit_buy) if x2==true strategy.order("buy2", strategy.long, qty=buy_qty) strategy.exit("close2", from_entry="buy2", stop=stop_buy, limit=profit_buy) if x3==true strategy.order("buy3", strategy.long, qty=buy_qty) strategy.exit("close3", from_entry="buy3", stop=stop_buy, limit=profit_buy) if x4==true strategy.order("buy4", strategy.long, qty=buy_qty) strategy.exit("close4", from_entry="buy4", stop=stop_buy, limit=profit_buy) if x5==true strategy.order("buy5", strategy.long, qty=buy_qty) strategy.exit("close5", from_entry="buy5", stop=stop_buy, limit=profit_buy) if r1==true strategy.order("buy6", strategy.long, qty=buy_qty) strategy.exit("close6", from_entry="buy6", stop=stop_buy, limit=profit_buy) if r2==true strategy.order("buy7", strategy.long, qty=buy_qty) strategy.exit("close7", from_entry="buy7", stop=stop_buy, limit=profit_buy) if r3==true strategy.order("buy8", strategy.long, qty=buy_qty) strategy.exit("close8", from_entry="buy8", stop=stop_buy, limit=profit_buy) if r4==true strategy.order("buy9", strategy.long, qty=buy_qty) strategy.exit("close9", from_entry="buy9", stop=stop_buy, limit=profit_buy) if r5==true strategy.order("buy10", strategy.long, qty=buy_qty) strategy.exit("close10", from_entry="buy10", stop=stop_buy, limit=profit_buy) if h1==true strategy.order("buy11", strategy.long, qty=buy_qty) strategy.exit("close11", from_entry="buy11", stop=stop_buy, limit=profit_buy) if h2==true strategy.order("buy12", strategy.long, qty=buy_qty) strategy.exit("close12", from_entry="buy12", stop=stop_buy, limit=profit_buy) if h3==true strategy.order("buy13", strategy.long, qty=buy_qty) strategy.exit("close13", from_entry="buy13", stop=stop_buy, limit=profit_buy) if h4==true strategy.order("buy14", strategy.long, qty=buy_qty) strategy.exit("close14", from_entry="buy14", stop=stop_buy, limit=profit_buy) if h5==true strategy.order("buy15", strategy.long, qty=buy_qty) strategy.exit("close15", from_entry="buy15", stop=stop_buy, limit=profit_buy) sell_qty=(100/(((highest(high,period_)-close[0])*100000)))*100000 stop_sell=highest(high, period_) profit_sell=close-((highest(high, period_)-close)*tp_sl_ratio) if y1==true strategy.order("sell1", strategy.short, qty=sell_qty) strategy.exit("close1", from_entry='sell1',stop=stop_sell, limit=profit_sell) if y2==true strategy.order("sell2", strategy.short, qty=sell_qty) strategy.exit("close2", from_entry='sell2',stop=stop_sell, limit=profit_sell) if y3==true strategy.order("sell3", strategy.short, qty=sell_qty) strategy.exit("close3", from_entry='sell3',stop=stop_sell, limit=profit_sell) if y4==true strategy.order("sell4", strategy.short, qty=sell_qty) strategy.exit("close4", from_entry='sell4',stop=stop_sell, limit=profit_sell) if y5==true strategy.order("sell5", strategy.short, qty=sell_qty) strategy.exit("close5", from_entry='sell5',stop=stop_sell, limit=profit_sell) if t1==true strategy.order("sell6", strategy.short, qty=sell_qty) strategy.exit("close6", from_entry='sell6',stop=stop_sell, limit=profit_sell) if t2==true strategy.order("sell7", strategy.short, qty=sell_qty) strategy.exit("close7", from_entry='sell7',stop=stop_sell, limit=profit_sell) if t3==true strategy.order("sell8", strategy.short, qty=sell_qty) strategy.exit("close8", from_entry='sell8',stop=stop_sell, limit=profit_sell) if t4==true strategy.order("sell9", strategy.short, qty=sell_qty) strategy.exit("close9", from_entry='sell9',stop=stop_sell, limit=profit_sell) if t5==true strategy.order("sell10", strategy.short, qty=sell_qty) strategy.exit("close10", from_entry='sell10',stop=stop_sell, limit=profit_sell) if g1==true strategy.order("sell11", strategy.short, qty=sell_qty) strategy.exit("close11", from_entry='sell11',stop=stop_sell, limit=profit_sell) if g2==true strategy.order("sell12", strategy.short, qty=sell_qty) strategy.exit("close12", from_entry='sell12',stop=stop_sell, limit=profit_sell) if g3==true strategy.order("sell13", strategy.short, qty=sell_qty) strategy.exit("close13", from_entry='sell13',stop=stop_sell, limit=profit_sell) if g4==true strategy.order("sell14", strategy.short, qty=sell_qty) strategy.exit("close14", from_entry='sell14',stop=stop_sell, limit=profit_sell) if g5==true strategy.order("sell15", strategy.short, qty=sell_qty) strategy.exit("close15", from_entry='sell15',stop=stop_sell, limit=profit_sell)