clone337
clone337

Reputation: 1

Pinescript V6 Label text placement

THis may be a simple fix but I'm just starting out. I am plotting buy/sell labels on a simple EMA cross. I can get the sell labels and text to plot correctly, but the buy text is plotting above the candle bar when it should be plotting above. Any ideas would be appreciated.

Image of output

// User inputs for label style, position, and size
label_style = input.string("Label Up", title="Label Style", options=["Label Up", "Label Down", "Circle", "Square", "Triangle Up", "Triangle Down", "Flag", "Arrow Up", "Arrow Down"])
label_position_buy = input.string("Below Candle", title="Buy Label Position", options=["Above Candle", "Below Candle"])
label_position_sell = input.string("Above Candle", title="Sell Label Position", options=["Above Candle", "Below Candle"])
label_size = input.string("Small", title="Label Size", options=["Tiny", "Small", "Normal", "Large"])

// Function to determine label Y position dynamically
get_label_y(position, high, low) =>
    position == "Above Candle" ? high + ta.atr(1) * 0.5 : low - ta.atr(1) * 0.5

// Plot buy and sell signals on the chart
// Add labels for Long and Short signals
if sell_signal
    label.new(x = bar_index, y = low, text = str.tostring(close, format.mintick), color = color.new(color.white, 100), textcolor = color.green, style = label.style_label_up, yloc = yloc.belowbar, size = getTextSize(label_size(size)))

if buy_signal
    label.new(x = bar_index, y = high, text = str.tostring(close, format.mintick), color = color.new(color.white, 100), textcolor = color.red, style = label.style_label_down, yloc = yloc.abovebar, size = getTextSize(label_size(size)))

I tried using Claud to debug but it cannot determine the fix. I get syntax errors when it tries to update the code. I reviewed the V6 manual and it looks ok to me.

Upvotes: 0

Views: 97

Answers (0)

Related Questions