The Ganesh Trend
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gshedge63

//@version=4
study(title="The Ganesh Trend - Nifty", overlay=true)

float call_sl = na
float put_sl = na
float call_tg = na
float put_tg = na

High = max(high,high[1])
Low = min(low,low[1])
//buy = (close>open) and ((high-close)<=(0.33*(high-low))) and ((open-low)<=0.05*(high-low))
Hammer = (close>open) and ((high-close)<=(0.25*(high-low)))  and ((high-low)>=0.0011*(low)) and (open-low)>=0.45*(high-low) and (close-low)<=81
Hammer2 = (close>open[1]) and (open<close) and ((High-close)<=(0.25*(High-Low)))  and ((High-Low)>=0.0012*(low)) and (open[1]-Low)>=0.45*(High-Low) and (close-Low)<=101
//sell = (open>close) and ((close-low)<=(0.33*(high-low))) and ((high-open)<=0.05*(high-low))
Ihammer = (open>close) and ((close-low)<=(0.25*(high-low)))  and ((high-low)>=0.0011*(low)) and (high-open)>=0.45*(high-low) and (high-close)<=81
Ihammer2 = (close<open[1]) and (close<open) and ((close-Low)<=(0.25*(High-Low)))  and ((High-Low)>=0.0012*(low)) and (High-open[1])>=0.45*(High-Low) and (High-close)<=101

if Hammer==true
    call_sl := int(low - 0.5*(high-low))
    call_tg := int(high + 1.5*(high-call_sl))
else if Hammer2==true
    call_sl := int(Low - 0.2*(High-Low))
    call_tg := int(High + 1.5*(High-call_sl))
else if Ihammer==true
    put_sl := int(high + 0.5*(high-low))
    put_tg := int(low - 1.5*(put_sl-low))
else if Ihammer2==true
    put_sl := int(High + 0.2*(High-Low))
    put_tg := int(Low - 1.5*(put_sl-Low))

plotshape(Hammer==true or Hammer2==true, location=location.belowbar, text="CALL", textcolor=color.white, style=shape.arrowup, size=size.normal, color=color.green)
plotshape(Ihammer==true or Ihammer2==true , location=location.abovebar, text="PUT", textcolor=color.white, style=shape.arrowdown, size=size.normal, color=color.red)
plot(call_sl, color=color.red, linewidth=1,style=plot.style_circles)
plot(put_sl, color=color.red, linewidth=1,style=plot.style_circles)
plot(call_tg, color=color.green, linewidth=2,style=plot.style_circles)
plot(put_tg, color=color.green, linewidth=2,style=plot.style_circles)