-2

I have an error message at the LongCondition statement but cannot understand why. Can you help me find proper code ?

I have tried this for the LongBuy condition but returns an error message

// Script inputs
string GROUP_DLB = 'Config » Dynamic Level Breakouts'
length = input.int(defval=20, title="Period", group=GROUP_DLB, minval=2, maxval=30) // 20 or 15
//riskration = input.float(defval = 1.5, title="Risk Ratio", group=GROUP_DLB)

// Calculate maximum and minimum price in the rolling window

max_level = ta.highest(high, length)
min_level = ta.lowest(low, length)

// Define condtions for dynamic support and resistance levels detection and plotting

max_color_cond = (max_level[1]==max_level[2]) and (close[1]<=max_level[1]) and (close[1]>=min_level[1])
min_color_cond = (min_level[1]==min_level[2]) and (close[1]<=max_level[1]) and (close[1]>=min_level[1])

// Define conditional coloring for dynamic support and resistance levels

max_level_color = max_color_cond ? color.new(color.red,0):na
min_level_color = min_color_cond ? color.new(color.green,0):na

// Define bullish and bearish breakouts condition

bullish_breakout = ta.crossover (close, max_level[1])
bearish_breakout = ta.crossunder (close, min_level[1]) 

//Plot dynamic support and resistance levels

plot(max_level[1], color = max_level_color,linewidth=2)
plot(min_level[1], color = min_level_color,linewidth=2)

// Define a current market regime condition

not_bullish = ta.barssince(bullish_breakout[1])>ta.barssince(bearish_breakout[1])
not_bearish = ta.barssince(bullish_breakout[1])<ta.barssince(bearish_breakout[1])

// Long and short alerts
LongBuy = bullish_breakout == true and not_bullish == true
ShortSell = bearish_breakout and not_bearish

// Plot dynamic support and resistance levels breakout signals

plotshape(bullish_breakout and not_bullish, text="▲", style=shape.labelup, color=color.green, textcolor=color.white, location=location.belowbar, size=size.small)
plotshape(bearish_breakout and not_bearish, text="▼", style=shape.labeldown, color=color.red, textcolor=color.white, location=location.abovebar, size=size.small)

// Order taking
if LongBuy
   strategy.entry('Long', strategy.long)
Dan64
  • 1

0 Answers0