Elephant - Shooting Star Candles
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ihsuka942
//@version=4
study("Elephant - Shooting Star Candles", overlay=true)
len = input(defval=100,minval = 0, title="Period", type=input.integer)
CS = input(defval=70,minval = 0,maxval = 100, title="Elephant Body size  (0-100)%", type=input.float)
ss = input(defval=50,minval = 0,maxval = 50, title="ShootingStar Body size  (0-100)%", type=input.float)
Nstd = input(defval=1.3,minval = 0, title="Confidence Level in Standard deviations for Elephant bars", type=input.float)
Nstd2 = input(defval=1.3,minval = 0, title="Confidence Level in Standard deviations for Shooting Star", type=input.float)
cs = (close - open)/low
ws = (high - low)/low
p = sma(cs,len)+Nstd*stdev(cs,len)
m = sma(cs,len)-Nstd*stdev(cs,len)
p2 = sma(ws,len)+Nstd2*stdev(ws,len)

center = (high+low)/2

backgroundele = cs < m and abs(cs) > CS*(ws)/100  and close < sma(close,200) ? color.red:
     cs > p and abs(cs) > CS*(ws)/100 and close >  sma(close,200) ? color.green :
     na
 
backgroundrockets = ws > p2 and  abs(cs) > 0.0  and  abs(cs) < ss*(ws)/100  and open > center and close > center? color.green:
     ws > p2 and  abs(cs) > 0.0  and  abs(cs) < ss*(ws)/100 and open < center and close < center ? color.red:
     na
bgcolor(color=backgroundele,title ='Elephant Bars', transp=50)
bgcolor(color=backgroundrockets,title ='ShootingStart Bars', transp=30)
