AleksandrLombrozo

Engulfing below EMA 120

Buy bullish engulfing above EMA 24
Sell bullish engulfing below EMA 24
Mercurius A.M.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//@version=2
strategy("engulfing", pyramiding=20)
//модуль тела свечи
body=abs(open-close)
//цвет свечи: красная или зеленая
colour=open>close
//взвешенная сс
ema_1D=ema(close,5)
period_ema=input(defval=120,title="period_ema",type=integer, minval=1, maxval=500, step=5)
ema_1h=ema(close,period_ema)
ema_24=ema(close,24)
//верхняя тень
up_shadow=abs(high-close)
//бычья сила бычей свечи
from_down_power=abs(low-close)
//нижняя тень
down_shadow=abs(low-close)
//медвежья сила медвежей свечи
from_up_power=abs(high-close)
m=rsi(close,6)
rsi_slow=rsi(close,12)
rsi_fast=rsi(close,6)
x=((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)
y=((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)
w=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]>open[1] and ema_1h[0]>ema_1h[1] and colour[0]==false and colour[1]==true and from_down_power[0]>up_shadow[0] and up_shadow[0]<body[0] and isintraday and rsi_slow<rsi_fast) 
e=((body[0]>body[1] or ((body[0]+body[1])>body[2])) and close[0]<open[1] and ema_1h[0]<ema_1h[1] and colour[0]==true and colour[1]==false and from_up_power[0]>down_shadow[0] and down_shadow[0]<body[0] and isintraday and rsi_slow>rsi_fast) 
r=close[0]>close[1] and  colour[0]==false and colour[1]==true and isdwm and open[0]<close[1]
t=close[0]<close[1] and  colour[0]==true and colour[1]==false and isdwm and open[0]>close[1]
period_=input(defval=1,title="period_",type=integer, minval=1, maxval=100, step=1)
buy_qty=(200/(((close[0]-lowest(low,period_))*100000)))*100000
stop_buy=lowest(low, period_)
profit_buy=((close[0]-lowest(low,period_))*2)*100000
strategy.entry("buy", strategy.long, qty=buy_qty, when=w)
strategy.exit("close", from_entry=strategy.position_entry_name, stop=stop_buy, profit=profit_buy, when=w)
sell_qty=(200/(((highest(high,period_)-close[0])*100000)))*100000
stop_sell=highest(high, period_)
profit_sell=((highest(high,period_)-close[0])*2)*100000
strategy.entry("sell", strategy.short, qty=sell_qty, when=e)
strategy.exit("close", from_entry=strategy.position_entry_name, stop=stop_sell, profit=profit_sell, when=e)
plot(strategy.equity)