OPEN-SOURCE SCRIPT
Diupdate

15% Discount Overlay

120
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:
Catatan Rilis
//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)

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.