flat = na flat := not inLongPosition and not inShortPosition
alertcondition(goLong and (inShortPosition or flat),title='Alert Long', message='Long') alertcondition(goShort and (inLongPosition or flat),title='Alert Short', message='Short!')
plotshape(goLong and (inShortPosition or flat), title='Long', location=location.abovebar, style=shape.labelup,textcolor=white, color=green, text="[LONG]", transp=0,offset=Offset) plotshape(goShort and (inLongPosition or flat),title='Short',location=location.belowbar, style=shape.labelup, textcolor=white, color=red, text="[SHORT]", transp=0,offset=Offset)