1

Here is the indicator I am trying to code:

//@version=5
indicator("Ell8 BEC", overlay=true)

var float prevBearSize = na
var float currBullSize = na

if close[2] < open[2]
    prevBearSize := abs(close[2] - open[2])

if open[0] < close[0] 
    currBullSize := abs(close[0] - open[0])

if open[0] < close[0] and (open[1] == close[2]) and (close[1] < open[1]) and prevBearSize * 2 < abs(open[1]) - close[1] and currBullSize * 3 < prevBearSize
    plotshape("Bullish Pattern", style=shape.arrowup, textcolor=color.white, location=location.belowbar,color=color.green, size=size.large, transp=0)
    else
     plot(na)

Tried indenting the line; bracketing some of the expressions.

1 Answers1

0

You had some problems with indentation in your code.
Then, you must use math.abs instead of abs.
Then you must tell pinescript the level you need to plot with plotshape. And you can't use plotshape in a local scope (after an if for example). So you must use a variable to use in plotshape.
And this variable will be 'na' if you donc want to plot : plotshape with na does'nt plot anytihing. Here is the corrected code :

//@version=5
indicator("Ell8 BEC", overlay=true)

var float prevBearSize = na
var float currBullSize = na

if close[2] < open[2]
    prevBearSize := math.abs(close[2] - open[2])

if open[0] < close[0] 
    currBullSize := math.abs(close[0] - open[0])

Level = close
if not(open[0] < close[0] and (open[1] == close[2]) and (close[1] < open[1]) and prevBearSize * 2 < math.abs(open[1]) - close[1] and currBullSize * 3 < prevBearSize)
    Level := na

plotshape(Level, "Bullish Pattern", style=shape.arrowup, textcolor=color.new(color.blue, 0), location=location.belowbar,color=color.green, size=size.large)
G.Lebret
  • 2,826
  • 2
  • 16
  • 27