Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Price_in_HUF", "HUFprice", false)
- referenceEnabled = input.bool(true, "Enable reference")
- referencePrice = input.price(122110.0, "Reference price", "The percentage difference is calculated with this price.")
- nl = "\n"
- currencyInHUF = 0.0
- symbolName = syminfo.currency + "HUF"
- selectedSymbolText = symbolName
- currencyInHUF := request.security(symbolName, "1M", close)
- currentPriceHUF = close * currencyInHUF
- diffpercent = ((currentPriceHUF - referencePrice) / referencePrice) * 100
- diffPrice = (currentPriceHUF - referencePrice)
- printTable(txt, refTxt, diffTxt, refEnabled) =>
- if refEnabled
- var table t = table.new(position.middle_right, 1, 4),
- table.cell(t, 0, 0, selectedSymbolText, bgcolor = color.rgb(47, 255, 158)),
- table.cell(t, 0, 1, refTxt, bgcolor = color.white),
- table.cell(t, 0, 2, txt, bgcolor = color.rgb(151, 255, 206)),
- table.cell(t, 0, 3, diffTxt, bgcolor = color.white),
- else
- var table t = table.new(position.middle_right, 1, 2),
- table.cell(t, 0, 0, selectedSymbolText, bgcolor = color.rgb(47, 255, 158)),
- table.cell(t, 0, 1, txt, bgcolor = color.white)
- referenceText = "Reference price:" + nl + str.tostring(referencePrice, "#,###") + " Ft"
- displayText = "Current price:" + nl + str.tostring(currentPriceHUF, "#,###") + " Ft"
- diffText = "Difference:" + nl + str.tostring(diffPrice, "#,###") + " Ft" + nl + str.tostring(diffpercent, "#.##") + " %"
- printTable(displayText, referenceText, diffText, referenceEnabled)
- plot(currentPriceHUF, "Price in HUF", color.yellow)
- plot(referencePrice, "Reference price", color.rgb(55, 255, 109), 3)
Advertisement
Comments
-
- i got all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement