Price Action Signals
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sonnyparlin

// 6/4/2022 Changed plot arrows 

//@version=5
indicator("Price Action Signals", overlay=true)
upperTail = (high - close)
lowerTail = (open - low)
thePlot = (lowerTail-upperTail)

// cond1
// 1m chart = .1
// 5min chart =.15
// 15m char = .25
// 1 hour char = 1.00
// 1 day chart = 2.00
absStop = input.float(.25, step=0.1, title="How much price moves during one candle.")

cond1 = math.abs(open-close) < absStop
cond2Input = input.float(20, step=10, title="Length of candle wick must be x% the length of the candle body.")

// cond2
// 0.25, only show arrow if wick is at least 25% the length of the candle's body
cond2 = math.abs(lowerTail-upperTail) < (math.abs(close-open) * (cond2Input / 100))
// if (math.abs(close-open) > absStop)
//     cond2 := false

days = input.int(20, step=1, title="Length for moving average")

// Only show bearish arrows if the price is above 20 day ma
cond3 = (lowerTail > upperTail and close > ta.rma(close, days))

// Only show bullish arrows if the price is below the 20 day ma
cond4 = (upperTail > lowerTail and close < ta.rma(close, days))


if (cond1 or cond2 or cond3 or cond4)
    thePlot := 0
    
redPlot = thePlot
greenPlot = thePlot

if (lowerTail > upperTail)
    redPlot:= 0
    
if (lowerTail < upperTail)
    greenPlot:= 0


//plotarrow(thePlot, colorup = color.teal, colordown = color.orange)
plotshape(redPlot, style=shape.triangledown,
                 location=location.abovebar, color=color.red)

plotshape(greenPlot, style=shape.triangleup,
                 location=location.belowbar, color=color.green)

