OPEN-SOURCE SCRIPT
ที่อัปเดต:

15% Discount Overlay

121
If you want to implement this in a strategy context on TradingView, we need to use the strategy() function to create a backtestable strategy that calculates 15% off the current price and displays a label on the chart.

Below is the updated script that includes the strategy() function. This will allow you to execute a basic strategy while still displaying the label for the 15% off price:
เอกสารเผยแพร่
//version=6
indicator("15% Discount Overlay", overlay=true)

// Get the current close price
current_price = close

// Calculate the 15% discount
discount_price = current_price * 0.85

// Plot the discount price as a line
plot(discount_price, color=color.blue, linewidth=2, title="Normal")
plot(close, color=color.red, linewidth=2, title="15% Discount")

if bar_index % 10 == 0 or bar_index == last_bar_index
label.new(bar_index, close, text=str.tostring(close, "#.##"), style=label.style_label_up, color=color.white, textcolor=color.red, size=size.small)
label.new(bar_index, discount_price, text=str.tostring(discount_price, "#.##"), style=label.style_label_up, color=color.white, textcolor=color.blue, size=size.small)

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน