LowHighFinder
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © xjtlumedia

//@version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © xjtlumedia

//@version=5


indicator("LowHighFinder v2")
//inputs
emaline = input.int( 5, "EMA control line", minval = 3,maxval = 20, group = "EMA conntrol line" )
leng2 = input.int( 5, "Output line length", minval = 1,maxval = 20, group = "output line" )
multiplierv  = input.int( 1, "Vol Multiplier", minval = 1,maxval = 20 , group = "Cotrol  vol multipler" )
multipliero  = input.int( 1, "Open Multiplier", minval = 1,maxval = 20 , group = "Cotrol open multipler" )
multiplierl = input.int( 1, "Low Multiplier", minval = 1,maxval = 20 , group = "Cotrol low multipler" )
multiplierh  = input.int( 1, "High Multiplier", minval = 1,maxval = 20 , group = "Cotrol high multipler" )
multiplierc  = input.int( 1, "Close Multiplier", minval = 1,maxval = 20 , group = "Cotrol close multipler" )
emamultipler  = input.int( 1, "EMA Multipler", minval = 1,maxval = 15 , group = "Cotrol EMA multipler" )
percentchange = input.int( 100, "Percent change(in 1/1000)", minval = 1,maxval = 1000 , group = "Cotrol percentchange" )
compares = input.int( 10, "Comparison line length", minval = 1,maxval = 100 , group = "Cotrol Comparison line length" )
linediff= input.int( 15, "Comparison line differences(in 1/1000)", minval = 1,maxval = 1000 , group = "Cotrol Comparison line differences" )
//calculation of K lines
src1=high
src2=low
src3=open
src4=close
voldiff=(volume-nz(volume[1]))/nz(volume[1])
odiff=(src3-nz(src3[1]))/nz(src3[1])
cdiff=(src4-nz(src4[1]))/nz(src4[1])
hdiff=(src1-nz(src1[1]))/nz(src1[1])
ldiff=(src2-nz(src2[1]))/nz(src2[1])
emadiff=(src4-nz(ta.ema(src4,emaline)))/ta.ema(src4,emaline)
volsignal=0.0
osignal=0.0
csignal=0.0
hsignal=0.0
lsignal=0.0
smoothsignal=0.0

//signal calculation 
volsignal:=voldiff>(percentchange/1000) ? 2*multiplierv : voldiff>0 and voldiff<(percentchange/1000) ? 1*multiplierv :voldiff<0 and voldiff>-(percentchange/1000) ? -1*multiplierv : -2*multiplierv
osignal:=odiff>(percentchange/1000) ? 2*multipliero: odiff>0 and odiff<(percentchange/1000) ? 1*multipliero :odiff<0 and odiff>-(percentchange/1000) ? -1*multipliero : -2*multipliero
lsignal:=ldiff>(percentchange/1000) ? 2*multiplierl: ldiff>0 and ldiff<(percentchange/1000) ? 1*multiplierl :ldiff<0 and voldiff>-(percentchange/1000) ? -1*multiplierl : -2*multiplierl
hsignal:=hdiff>(percentchange/1000) ? 2*multiplierh: hdiff>0 and hdiff<(percentchange/1000) ? 1*multiplierh :hdiff<0 and voldiff>-(percentchange/1000) ? -1*multiplierh : -2*multiplierh
csignal:=cdiff>(percentchange/1000) ? 2*multiplierc: cdiff>0 and cdiff<(percentchange/1000) ? 1*multiplierc :cdiff<0 and voldiff>-(percentchange/1000) ? -1*multiplierc : -2*multiplierc
smoothsignal:=emadiff>(percentchange/1000) ? 2*emamultipler: emadiff>0 and emadiff<(percentchange/1000) ? 1*emamultipler :emadiff<0 and emadiff>-(percentchange/1000) ? -1*emamultipler : -2*emamultipler

cvols=0.0
copens=0.0
ccloses=0.0
chighs=0.0
clows=0.0
cemas=0.0
cvols:=volsignal+cvols
copens:=osignal+copens
ccloses:=csignal+ccloses
chighs:=hsignal+chighs
clows:=lsignal+clows
cemas:=smoothsignal+cemas
    
compareup=0.0
comparedown=0.0
if ta.ema(src4,compares)>=src4 and (ta.ema(src4,compares)-src4)/ta.ema(src4,compares)>(linediff/1000)
    comparedown:=1
else
    comparedown:=0
if ta.ema(src4,compares)<src4 and (src4-ta.ema(src4,compares))/ta.ema(src4,compares)>(linediff/1000)
    compareup:=1
else
    compareup:=0
rsv=0.0
nrsv=0.0
rsv:=(cvols+ccloses+copens+chighs+clows-cemas)
nrsv:=ta.sma(rsv,leng2)
plot(0,color = color.gray)
p1=plot(2.5,color = color.green)
p2=plot(-2.5,color = color.red)
p3=plot(nrsv,color = color.rgb(189, 243, 81))

plotshape(nrsv<-2.5 and comparedown==1, title="Long Entry Point Warning", location=location.bottom, style=shape.circle, size=size.tiny, color=color.lime)
plotshape(nrsv>2.5 and compareup==1, title="Short Entry Point Warning", location=location.top, style=shape.circle, size=size.tiny, color=color.red)