1
//@dztrctstar
//@version=5
indicator("My script")
coinToss = math.random(0, 1)
if (coinToss > 0.5)
    arrowSeries = 1
else
    arrowSeries = 0

shapeType = if arrowSeries == 1
    shape.arrowup
else
    shape.arrowdown


plotshape(
    shapeType,
    x = 0,
    y = arrowSeries,
    color = if arrowSeries == 1
        color.green
    else
        color.red

)

iam getting 11:46:06 AM — Compilation error. Line 16: Syntax error at input 'end of line without line continuation'

But if i remove complete code block in line 16 iam still getting errors in other if blocks can anyone tellme what should i do

I tried checking indentations and also changed other indentations but iam not getting any result

1 Answers1

0

You cannot write a whole if statement inside plotshape().

Either do that in the global scope and use the result to assign the color value, or use the ternary operator.

Also, you are defining arrowSeries in a local block. Then use it later in an if statement which will not work. Because it won’t be visible there.

vitruvius
  • 15,740
  • 3
  • 16
  • 26