Hello, Nikolas.
Can you check correct programming and if necessary put it in the library so not done? See below…
Part1 .. PG Indicator
// PopGun Indicator
// coded by JohnScher
//for the graphics
PIP = 10*pipsize
LIN = 3
//percentrenage = Support or Resistance in Percent og the Range High-Low = 25% default
Support = (High-Low)*percentrange/100
Resistance = (High-Low)*percentrange/100
//indicator PopGun
PG = High[2]>High[1] and Low[2]<Low[1] and High>High[1] and Low<Low[1]
// the second outside candle
PGLong = PG and Close>open // greencandle = long , as rerversal short
PGShort = PG and Close<Open //redcandle = short, as reversal long
IF PGLong Then
rL=0
gL=0
bL=250
DRAWARROWUP(barindex,LOW-PIP)coloured(rL,gL,bL)
DRAWSEGMENT(barindex,LOW-SUPPORT,barindex+LIN, LOW-SUPPORT )coloured(rL,gL,bL)
// to trade as reversal red candle = Long
rL=250
gL=0
bL=250
DRAWARROWDOWN(barindex,HIGH+PIP)coloured(rs,gs,bs)
DRAWSEGMENT(barindex,High+Resistance,barindex+LIN, High+Resistance )coloured(rs,gs,bs)
Endif
IF PGShort then
rS=250
gS=0
bS=00
DRAWARROWDOWN(barindex,HIGH+PIP)coloured(rs,gs,bs)
DRAWSEGMENT(barindex,High+Resistance,barindex+LIN, High+Resistance )coloured(rs,gs,bs)
// to trade as reversal red candle = Long
rL=0
gL=0
bL=250
DRAWARROWUP(barindex,LOW-PIP)coloured(rL,gL,bL)
DRAWSEGMENT(barindex,LOW-SUPPORT,barindex+LIN, LOW-SUPPORT )coloured(rL,gL,bL)
ENDIF
return
Part2… PG Screener
// PopGun screener
// coded by JohnScher and robertogozzi
PG = High[2]>High[1] and Low[2]<Low[1] and High>High[1] and Low<Low[1]
PGLong = PG and Close>open
PGShort = PG and Close<Open
x = 0
IF PGLong Then
x = 1
Endif
IF PGShort then
x = -1
ENDIF
SCREENER[x](x as "PG")
Part3 .. Backtest whether the PG is effective
// PopGun Backtest
// coded by JohnScher
p = 5 // could be outside
PG = High[p+2]>High[p+1] and Low[p+2]<Low[p+1] and High [p]>High[p+1] and Low [p]<Low[p+1]
PGLong = PG and Close>open
PGShort = PG and Close<Open
d = 0.5 // distance 0.1 0.25 0.5 0.75 ... could be outside too
distance = (High [p] - Low [p])*d
q = p-1
c1 = Highest [q] (high) < (High [p] + distance)
c2 = Lowest [q ] (low) > (Low [p] - distance)
x = 0
IF PGLong and c1 and c2 Then
x = 1
Endif
IF PGShort and c1 and c2 then
x = -1
ENDIF
SCREENER[x](x as "PG")
Geht?