You are here: home » pinescript » demonstrations » draw_label
Translations of this page:
  • en

DRA0.09 - ATM_LabelDraw Indicator

This is a code to draw a label which displays the At The Money Strike as per the first 5 minute candle on an Index chart.

  1. // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © rahuld0890
  3.  
  4. //@version=6
  5. indicator("DRA0.09 - ATM_LabelDraw Indicator", overlay=true, precision=0)
  6.  
  7. // Get 5-minute timeframe values
  8. var float dailyFirstClose = na
  9. var int firstCloseBarIndex = na
  10.  
  11. // Check for new day in 5-minute timeframe
  12. isNewDay = ta.change(time("D")) != 0
  13.  
  14. // Capture first 5-minute open/close on new day
  15. if isNewDay
  16. dailyFirstClose := close
  17. firstCloseBarIndex := bar_index
  18. else
  19. // Carry forward previous values
  20. dailyFirstClose := dailyFirstClose[1]
  21.  
  22. // Calculate ATM Strike Price
  23. atm_strike = math.round(dailyFirstClose / 100) * 100
  24.  
  25. // Plot hidden series to display in Data Window
  26. plot(atm_strike, title="ATM Strike Price", display=display.none)
  27.  
  28. // Optional: Display as text on chart
  29. var label atmLabel = label.new(na, na, "", style=label.style_label_left, size=size.small)
  30. label.set_xy(atmLabel, firstCloseBarIndex, dailyFirstClose)
  31. label.set_text(atmLabel, "ATM: " + str.tostring(atm_strike))
Edit this page
Back to top