Advertisement
zoltanvi

TradingView indicator

Sep 22nd, 2023 (edited)
1,054
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=5
  2.  
  3. indicator("Price_in_HUF", "HUFprice", false)
  4.  
  5. referenceEnabled = input.bool(true, "Enable reference")
  6. referencePrice = input.price(122110.0, "Reference price", "The percentage difference is calculated with this price.")
  7.  
  8. nl = "\n"
  9. currencyInHUF = 0.0
  10.  
  11. symbolName = syminfo.currency + "HUF"
  12.  
  13. selectedSymbolText = symbolName
  14.  
  15. currencyInHUF := request.security(symbolName, "1M", close)
  16.  
  17. currentPriceHUF = close * currencyInHUF
  18. diffpercent = ((currentPriceHUF - referencePrice) / referencePrice) * 100
  19. diffPrice = (currentPriceHUF - referencePrice)
  20.  
  21. printTable(txt, refTxt, diffTxt, refEnabled) =>
  22.     if refEnabled
  23.         var table t = table.new(position.middle_right, 1, 4),
  24.         table.cell(t, 0, 0, selectedSymbolText, bgcolor = color.rgb(47, 255, 158)),
  25.         table.cell(t, 0, 1, refTxt, bgcolor = color.white),
  26.         table.cell(t, 0, 2, txt, bgcolor = color.rgb(151, 255, 206)),
  27.         table.cell(t, 0, 3, diffTxt, bgcolor = color.white),
  28.     else
  29.         var table t = table.new(position.middle_right, 1, 2),
  30.         table.cell(t, 0, 0, selectedSymbolText, bgcolor = color.rgb(47, 255, 158)),
  31.         table.cell(t, 0, 1, txt, bgcolor = color.white)
  32.  
  33. referenceText = "Reference price:" + nl + str.tostring(referencePrice, "#,###") + " Ft"
  34. displayText = "Current price:" + nl + str.tostring(currentPriceHUF, "#,###") + " Ft"
  35. diffText = "Difference:" + nl + str.tostring(diffPrice, "#,###") + " Ft" + nl + str.tostring(diffpercent, "#.##") + " %"
  36.  
  37. printTable(displayText, referenceText, diffText, referenceEnabled)
  38.  
  39. plot(currentPriceHUF, "Price in HUF", color.yellow)
  40. plot(referencePrice, "Reference price", color.rgb(55, 255, 109), 3)
  41.  
Advertisement
Comments
  • hemal9022
    276 days
    # text 0.12 KB | 0 0
    1. 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