Indicator · Pine Script v6 · On the chart

LunarTick Levels

by lunarticktrading· code credited to gambcl

LunarTick Levels plots key daily reference levels and multi-timeframe simple moving averages directly on the price chart.

View on GitHub

GitHub stars7on the repository
Pine versionv6current
Lines of code662
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update2 weeks ago10 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

662 lines of Pine Script v6 from LunarTick Levels.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

LunarTick Levels.txt
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gambcl

//@version=6
indicator("LunarTick Levels", overlay = true, max_lines_count = 500, max_labels_count = 500)


////////////////////////////////////////////////////////////////////////////////////////////////////
// Version History
////////////////////////////////////////////////////////////////////////////////////////////////////
// v1.2.4
// - Use real OHLC values (in case of Heikin Ashi chart)
// v1.2.3
// - Limit max length of lines
// v1.2.2
// - Added limits to label offset, transparency
// v1.2.1
// - Prevent mintick rounding of label values
// v1.2.0
// - Added option to extend SMA levels
// v1.1.0
// - Support text-only labels
// v1.0.0
// - Initial release
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
// Imports
////////////////////////////////////////////////////////////////////////////////////////////////////

import gambcl/LunarTick/2


////////////////////////////////////////////////////////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////////////////////////////////////////////////////////

var DAILY_LEVELS_GROUP = "DAILY LEVELS"
var SMA_1H_GROUP = "1H MOVING AVERAGES"
var SMA_4H_GROUP = "4H MOVING AVERAGES"
var SMA_DAILY_GROUP = "DAILY MOVING AVERAGES"
var SMA_WEEKLY_GROUP = "WEEKLY MOVING AVERAGES"
var SMA_MONTHLY_GROUP = "MONTHLY MOVING AVERAGES"
var SESSIONS_GROUP = "SESSIONS"
var DISPLAY_GROUP = "DISPLAY"
var DEVELOPER_GROUP = "DEVELOPER"

var MAX_BARS_BACK = 5000

max_bars_back(time, MAX_BARS_BACK)


////////////////////////////////////////////////////////////////////////////////////////////////////
// Enums
////////////////////////////////////////////////////////////////////////////////////////////////////

enum LabelStyle
    none = "None"
    label_up = "Label Up"
    label_down = "Label Down"
    label_left = "Label Left"
    label_right = "Label Right"
    label_lower_left = "Label Lower Left"
    label_lower_right = "Label Lower Right"
    label_upper_left = "Label Upper Left"
    label_upper_right = "Label Upper Right"
    label_center = "Label Center"
    text_outline = "Text Outline"

enum LabelSize
    auto = "Auto"
    tiny = "Tiny"
    small = "Small"
    normal = "Normal"
    large = "Large"
    huge = "Huge"

enum LineStyle
    solid = "Solid"
    dashed = "Dashed"
    dotted = "Dotted"

enum VersionEnum
    version = "v1.2.4"
    

////////////////////////////////////////////////////////////////////////////////////////////////////
// Inputs
////////////////////////////////////////////////////////////////////////////////////////////////////

// Daily Levels
bool i_op_enabled = input.bool(true, "OP", inline = "OP", group = DAILY_LEVELS_GROUP, display = display.none, tooltip = "Opening Print")
color i_op_color = input.color(color.purple, "", inline = "OP", group = DAILY_LEVELS_GROUP, display = display.none)
LineStyle i_op_line_style = input.enum(LineStyle.dashed, "", inline = "OP", group = DAILY_LEVELS_GROUP, display = display.none)
int i_op_line_width = input.int(2, "", minval = 1, maxval = 4, inline = "OP", group = DAILY_LEVELS_GROUP, display = display.none)

bool i_pdh_enabled = input.bool(true, "PDH", inline = "PDH", group = DAILY_LEVELS_GROUP, display = display.none, tooltip = "Previous Daily High")
color i_pdh_color = input.color(color.red, "", inline = "PDH", group = DAILY_LEVELS_GROUP, display = display.none)
LineStyle i_pdh_line_style = input.enum(LineStyle.dashed, "", inline = "PDH", group = DAILY_LEVELS_GROUP, display = display.none)
int i_pdh_line_width = input.int(2, "", minval = 1, maxval = 4, inline = "PDH", group = DAILY_LEVELS_GROUP, display = display.none)

bool i_pdl_enabled = input.bool(true, "PDL", inline = "PDL", group = DAILY_LEVELS_GROUP, display = display.none, tooltip = "Previous Daily Low")
color i_pdl_color = input.color(color.green, "", inline = "PDL", group = DAILY_LEVELS_GROUP, display = display.none)
LineStyle i_pdl_line_style = input.enum(LineStyle.dashed, "", inline = "PDL", group = DAILY_LEVELS_GROUP, display = display.none)
int i_pdl_line_width = input.int(2, "", minval = 1, maxval = 4, inline = "PDL", group = DAILY_LEVELS_GROUP, display = display.none)

bool i_onh_enabled = input.bool(true, "ONH", inline = "ONH", group = DAILY_LEVELS_GROUP, display = display.none, tooltip = "Overnight High")
color i_onh_color = input.color(color.gray, "", inline = "ONH", group = DAILY_LEVELS_GROUP, display = display.none)
LineStyle i_onh_line_style = input.enum(LineStyle.dashed, "", inline = "ONH", group = DAILY_LEVELS_GROUP, display = display.none)
int i_onh_line_width = input.int(2, "", minval = 1, maxval = 4, inline = "ONH", group = DAILY_LEVELS_GROUP, display = display.none)

bool i_onl_enabled = input.bool(true, "ONL", inline = "ONL", group = DAILY_LEVELS_GROUP, display = display.none, tooltip = "Overnight Low")
color i_onl_color = input.color(color.gray, "", inline = "ONL", group = DAILY_LEVELS_GROUP, display = display.none)
LineStyle i_onl_line_style = input.enum(LineStyle.dashed, "", inline = "ONL", group = DAILY_LEVELS_GROUP, display = display.none)
int i_onl_line_width = input.int(2, "", minval = 1, maxval = 4, inline = "ONL", group = DAILY_LEVELS_GROUP, display = display.none)

// 1H SMA
bool i_sma1_1h_enabled = input.bool(false, "", inline = "SMA1_1H", group = SMA_1H_GROUP, display = display.none)
int i_sma1_1h_length = input.int(20, "", minval = 1, inline = "SMA1_1H", group = SMA_1H_GROUP, display = display.none)
color i_sma1_1h_color = input.color(color.fuchsia, "", inline = "SMA1_1H", group = SMA_1H_GROUP, display = display.none)
LineStyle i_sma1_1h_line_style = input.enum(LineStyle.solid, "", inline = "SMA1_1H", group = SMA_1H_GROUP, display = display.none)
int i_sma1_1h_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA1_1H", group = SMA_1H_GROUP, display = display.none)

bool i_sma2_1h_enabled = input.bool(true, "", inline = "SMA2_1H", group = SMA_1H_GROUP, display = display.none)
int i_sma2_1h_length = input.int(50, "", minval = 1, inline = "SMA2_1H", group = SMA_1H_GROUP, display = display.none)
color i_sma2_1h_color = input.color(color.fuchsia, "", inline = "SMA2_1H", group = SMA_1H_GROUP, display = display.none)
LineStyle i_sma2_1h_line_style = input.enum(LineStyle.solid, "", inline = "SMA2_1H", group = SMA_1H_GROUP, display = display.none)
int i_sma2_1h_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA2_1H", group = SMA_1H_GROUP, display = display.none)

bool i_sma3_1h_enabled = input.bool(true, "", inline = "SMA3_1H", group = SMA_1H_GROUP, display = display.none)
int i_sma3_1h_length = input.int(100, "", minval = 1, inline = "SMA3_1H", group = SMA_1H_GROUP, display = display.none)
color i_sma3_1h_color = input.color(color.fuchsia, "", inline = "SMA3_1H", group = SMA_1H_GROUP, display = display.none)
LineStyle i_sma3_1h_line_style = input.enum(LineStyle.solid, "", inline = "SMA3_1H", group = SMA_1H_GROUP, display = display.none)
int i_sma3_1h_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA3_1H", group = SMA_1H_GROUP, display = display.none)

bool i_sma4_1h_enabled = input.bool(true, "", inline = "SMA4_1H", group = SMA_1H_GROUP, display = display.none)
int i_sma4_1h_length = input.int(200, "", minval = 1, inline = "SMA4_1H", group = SMA_1H_GROUP, display = display.none)
color i_sma4_1h_color = input.color(color.fuchsia, "", inline = "SMA4_1H", group = SMA_1H_GROUP, display = display.none)
LineStyle i_sma4_1h_line_style = input.enum(LineStyle.solid, "", inline = "SMA4_1H", group = SMA_1H_GROUP, display = display.none)
int i_sma4_1h_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA4_1H", group = SMA_1H_GROUP, display = display.none)

// 4H SMA
bool i_sma1_4h_enabled = input.bool(false, "", inline = "SMA1_4H", group = SMA_4H_GROUP, display = display.none)
int i_sma1_4h_length = input.int(20, "", minval = 1, inline = "SMA1_4H", group = SMA_4H_GROUP, display = display.none)
color i_sma1_4h_color = input.color(color.maroon, "", inline = "SMA1_4H", group = SMA_4H_GROUP, display = display.none)
LineStyle i_sma1_4h_line_style = input.enum(LineStyle.solid, "", inline = "SMA1_4H", group = SMA_4H_GROUP, display = display.none)
int i_sma1_4h_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA1_4H", group = SMA_4H_GROUP, display = display.none)

bool i_sma2_4h_enabled = input.bool(true, "", inline = "SMA2_4H", group = SMA_4H_GROUP, display = display.none)
int i_sma2_4h_length = input.int(50, "", minval = 1, inline = "SMA2_4H", group = SMA_4H_GROUP, display = display.none)
color i_sma2_4h_color = input.color(color.maroon, "", inline = "SMA2_4H", group = SMA_4H_GROUP, display = display.none)
LineStyle i_sma2_4h_line_style = input.enum(LineStyle.solid, "", inline = "SMA2_4H", group = SMA_4H_GROUP, display = display.none)
int i_sma2_4h_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA2_4H", group = SMA_4H_GROUP, display = display.none)

bool i_sma3_4h_enabled = input.bool(true, "", inline = "SMA3_4H", group = SMA_4H_GROUP, display = display.none)
int i_sma3_4h_length = input.int(100, "", minval = 1, inline = "SMA3_4H", group = SMA_4H_GROUP, display = display.none)
color i_sma3_4h_color = input.color(color.maroon, "", inline = "SMA3_4H", group = SMA_4H_GROUP, display = display.none)
LineStyle i_sma3_4h_line_style = input.enum(LineStyle.solid, "", inline = "SMA3_4H", group = SMA_4H_GROUP, display = display.none)
int i_sma3_4h_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA3_4H", group = SMA_4H_GROUP, display = display.none)

bool i_sma4_4h_enabled = input.bool(true, "", inline = "SMA4_4H", group = SMA_4H_GROUP, display = display.none)
int i_sma4_4h_length = input.int(200, "", minval = 1, inline = "SMA4_4H", group = SMA_4H_GROUP, display = display.none)
color i_sma4_4h_color = input.color(color.maroon, "", inline = "SMA4_4H", group = SMA_4H_GROUP, display = display.none)
LineStyle i_sma4_4h_line_style = input.enum(LineStyle.solid, "", inline = "SMA4_4H", group = SMA_4H_GROUP, display = display.none)
int i_sma4_4h_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA4_4H", group = SMA_4H_GROUP, display = display.none)

// Daily SMA
bool i_sma1_d_enabled = input.bool(false, "", inline = "SMA1_D", group = SMA_DAILY_GROUP, display = display.none)
int i_sma1_d_length = input.int(20, "", minval = 1, inline = "SMA1_D", group = SMA_DAILY_GROUP, display = display.none)
color i_sma1_d_color = input.color(color.blue, "", inline = "SMA1_D", group = SMA_DAILY_GROUP, display = display.none)
LineStyle i_sma1_d_line_style = input.enum(LineStyle.solid, "", inline = "SMA1_D", group = SMA_DAILY_GROUP, display = display.none)
int i_sma1_d_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA1_D", group = SMA_DAILY_GROUP, display = display.none)

bool i_sma2_d_enabled = input.bool(true, "", inline = "SMA2_D", group = SMA_DAILY_GROUP, display = display.none)
int i_sma2_d_length = input.int(50, "", minval = 1, inline = "SMA2_D", group = SMA_DAILY_GROUP, display = display.none)
color i_sma2_d_color = input.color(color.blue, "", inline = "SMA2_D", group = SMA_DAILY_GROUP, display = display.none)
LineStyle i_sma2_d_line_style = input.enum(LineStyle.solid, "", inline = "SMA2_D", group = SMA_DAILY_GROUP, display = display.none)
int i_sma2_d_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA2_D", group = SMA_DAILY_GROUP, display = display.none)

bool i_sma3_d_enabled = input.bool(true, "", inline = "SMA3_D", group = SMA_DAILY_GROUP, display = display.none)
int i_sma3_d_length = input.int(100, "", minval = 1, inline = "SMA3_D", group = SMA_DAILY_GROUP, display = display.none)
color i_sma3_d_color = input.color(color.blue, "", inline = "SMA3_D", group = SMA_DAILY_GROUP, display = display.none)
LineStyle i_sma3_d_line_style = input.enum(LineStyle.solid, "", inline = "SMA3_D", group = SMA_DAILY_GROUP, display = display.none)
int i_sma3_d_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA3_D", group = SMA_DAILY_GROUP, display = display.none)

bool i_sma4_d_enabled = input.bool(true, "", inline = "SMA4_D", group = SMA_DAILY_GROUP, display = display.none)
int i_sma4_d_length = input.int(200, "", minval = 1, inline = "SMA4_D", group = SMA_DAILY_GROUP, display = display.none)
color i_sma4_d_color = input.color(color.blue, "", inline = "SMA4_D", group = SMA_DAILY_GROUP, display = display.none)
LineStyle i_sma4_d_line_style = input.enum(LineStyle.solid, "", inline = "SMA4_D", group = SMA_DAILY_GROUP, display = display.none)
int i_sma4_d_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA4_D", group = SMA_DAILY_GROUP, display = display.none)

// Weekly SMA
bool i_sma1_w_enabled = input.bool(false, "", inline = "SMA1_W", group = SMA_WEEKLY_GROUP, display = display.none)
int i_sma1_w_length = input.int(20, "", minval = 1, inline = "SMA1_W", group = SMA_WEEKLY_GROUP, display = display.none)
color i_sma1_w_color = input.color(color.navy, "", inline = "SMA1_W", group = SMA_WEEKLY_GROUP, display = display.none)
LineStyle i_sma1_w_line_style = input.enum(LineStyle.solid, "", inline = "SMA1_W", group = SMA_WEEKLY_GROUP, display = display.none)
int i_sma1_w_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA1_W", group = SMA_WEEKLY_GROUP, display = display.none)

bool i_sma2_w_enabled = input.bool(true, "", inline = "SMA2_W", group = SMA_WEEKLY_GROUP, display = display.none)
int i_sma2_w_length = input.int(50, "", minval = 1, inline = "SMA2_W", group = SMA_WEEKLY_GROUP, display = display.none)
color i_sma2_w_color = input.color(color.navy, "", inline = "SMA2_W", group = SMA_WEEKLY_GROUP, display = display.none)
LineStyle i_sma2_w_line_style = input.enum(LineStyle.solid, "", inline = "SMA2_W", group = SMA_WEEKLY_GROUP, display = display.none)
int i_sma2_w_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA2_W", group = SMA_WEEKLY_GROUP, display = display.none)

bool i_sma3_w_enabled = input.bool(true, "", inline = "SMA3_W", group = SMA_WEEKLY_GROUP, display = display.none)
int i_sma3_w_length = input.int(100, "", minval = 1, inline = "SMA3_W", group = SMA_WEEKLY_GROUP, display = display.none)
color i_sma3_w_color = input.color(color.navy, "", inline = "SMA3_W", group = SMA_WEEKLY_GROUP, display = display.none)
LineStyle i_sma3_w_line_style = input.enum(LineStyle.solid, "", inline = "SMA3_W", group = SMA_WEEKLY_GROUP, display = display.none)
int i_sma3_w_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA3_W", group = SMA_WEEKLY_GROUP, display = display.none)

bool i_sma4_w_enabled = input.bool(true, "", inline = "SMA4_W", group = SMA_WEEKLY_GROUP, display = display.none)
int i_sma4_w_length = input.int(200, "", minval = 1, inline = "SMA4_W", group = SMA_WEEKLY_GROUP, display = display.none)
color i_sma4_w_color = input.color(color.navy, "", inline = "SMA4_W", group = SMA_WEEKLY_GROUP, display = display.none)
LineStyle i_sma4_w_line_style = input.enum(LineStyle.solid, "", inline = "SMA4_W", group = SMA_WEEKLY_GROUP, display = display.none)
int i_sma4_w_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA4_W", group = SMA_WEEKLY_GROUP, display = display.none)

// Monthly SMA
bool i_sma1_m_enabled = input.bool(false, "", inline = "SMA1_M", group = SMA_MONTHLY_GROUP, display = display.none)
int i_sma1_m_length = input.int(20, "", minval = 1, inline = "SMA1_M", group = SMA_MONTHLY_GROUP, display = display.none)
color i_sma1_m_color = input.color(color.gray, "", inline = "SMA1_M", group = SMA_MONTHLY_GROUP, display = display.none)
LineStyle i_sma1_m_line_style = input.enum(LineStyle.solid, "", inline = "SMA1_M", group = SMA_MONTHLY_GROUP, display = display.none)
int i_sma1_m_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA1_M", group = SMA_MONTHLY_GROUP, display = display.none)

bool i_sma2_m_enabled = input.bool(true, "", inline = "SMA2_M", group = SMA_MONTHLY_GROUP, display = display.none)
int i_sma2_m_length = input.int(50, "", minval = 1, inline = "SMA2_M", group = SMA_MONTHLY_GROUP, display = display.none)
color i_sma2_m_color = input.color(color.gray, "", inline = "SMA2_M", group = SMA_MONTHLY_GROUP, display = display.none)
LineStyle i_sma2_m_line_style = input.enum(LineStyle.solid, "", inline = "SMA2_M", group = SMA_MONTHLY_GROUP, display = display.none)
int i_sma2_m_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA2_M", group = SMA_MONTHLY_GROUP, display = display.none)

bool i_sma3_m_enabled = input.bool(true, "", inline = "SMA3_M", group = SMA_MONTHLY_GROUP, display = display.none)
int i_sma3_m_length = input.int(100, "", minval = 1, inline = "SMA3_M", group = SMA_MONTHLY_GROUP, display = display.none)
color i_sma3_m_color = input.color(color.gray, "", inline = "SMA3_M", group = SMA_MONTHLY_GROUP, display = display.none)
LineStyle i_sma3_m_line_style = input.enum(LineStyle.solid, "", inline = "SMA3_M", group = SMA_MONTHLY_GROUP, display = display.none)
int i_sma3_m_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA3_M", group = SMA_MONTHLY_GROUP, display = display.none)

bool i_sma4_m_enabled = input.bool(true, "", inline = "SMA4_M", group = SMA_MONTHLY_GROUP, display = display.none)
int i_sma4_m_length = input.int(200, "", minval = 1, inline = "SMA4_M", group = SMA_MONTHLY_GROUP, display = display.none)
color i_sma4_m_color = input.color(color.gray, "", inline = "SMA4_M", group = SMA_MONTHLY_GROUP, display = display.none)
LineStyle i_sma4_m_line_style = input.enum(LineStyle.solid, "", inline = "SMA4_M", group = SMA_MONTHLY_GROUP, display = display.none)
int i_sma4_m_line_width = input.int(1, "", minval = 1, maxval = 4, inline = "SMA4_M", group = SMA_MONTHLY_GROUP, display = display.none)

// Sessions
string i_timezone = input.string("America/New_York", "Timezone", group = SESSIONS_GROUP, display = display.none)
string i_eth_session = input.session("1800-1700", "Electronic Trading Hours", group = SESSIONS_GROUP, display = display.none)
string i_rth_session = input.session("0930-1700", "Regular Trading Hours", group = SESSIONS_GROUP, display = display.none)
color i_eth_bg_color = input.color(color.new(color.orange, 85), "Electronic Trading Hours Background", group = SESSIONS_GROUP, display = display.none)

// Display
bool i_extend_sma_levels = input.bool(false, "Extend SMA Levels", group = DISPLAY_GROUP, display = display.none)

bool i_show_labels = input.bool(true, "Show Labels", group = DISPLAY_GROUP, display = display.none)
int i_label_offset = input.int(4, "Label Offset", minval = 1, maxval = 100, group = DISPLAY_GROUP, active = i_show_labels, display = display.none)
LabelStyle i_label_style = input.enum(LabelStyle.label_left, "Label Style", group = DISPLAY_GROUP, active = i_show_labels, display = display.none)
LabelSize i_label_size = input.enum(LabelSize.normal, "Label Size", group = DISPLAY_GROUP, active = i_show_labels, display = display.none)
int i_label_bg_transparency = input.int(0, "Label Transparency", minval = 0, maxval = 100, group = DISPLAY_GROUP, active = i_show_labels, display = display.none)
color i_label_text_color = input.color(color.white, "Label Text Color", group = DISPLAY_GROUP, active = i_show_labels, display = display.none)

// Developer
VersionEnum i_version = input.enum(VersionEnum.version, "Version", display = display.none, group = DEVELOPER_GROUP)


////////////////////////////////////////////////////////////////////////////////////////////////////
// Globals
////////////////////////////////////////////////////////////////////////////////////////////////////

var bool initialized = false
var string price_format = format.mintick
var int eth_start_time_hhmm = 0
var int eth_end_time_hhmm = 0
var int rth_start_time_hhmm = 0
var int rth_end_time_hhmm = 0


////////////////////////////////////////////////////////////////////////////////////////////////////
// Functions
////////////////////////////////////////////////////////////////////////////////////////////////////

can_show_timeframe(string tf) =>
    timeframe.in_seconds(tf) >= timeframe.in_seconds()

get_label_style(LabelStyle lbl_style) =>
    switch lbl_style
        LabelStyle.none => label.style_label_left
        LabelStyle.label_up => label.style_label_up
        LabelStyle.label_down => label.style_label_down
        LabelStyle.label_left => label.style_label_left
        LabelStyle.label_right => label.style_label_right
        LabelStyle.label_lower_left => label.style_label_lower_left
        LabelStyle.label_lower_right => label.style_label_lower_right
        LabelStyle.label_upper_left => label.style_label_upper_left
        LabelStyle.label_upper_right => label.style_label_upper_right
        LabelStyle.label_center => label.style_label_center
        LabelStyle.text_outline => label.style_text_outline
        => label.style_none

get_label_textalign(LabelStyle lbl_style) =>
    switch lbl_style
        LabelStyle.none => text.align_left
        LabelStyle.label_left => text.align_left
        LabelStyle.label_right => text.align_right
        LabelStyle.label_lower_left => text.align_left
        LabelStyle.label_lower_right => text.align_right
        LabelStyle.label_upper_left => text.align_left
        LabelStyle.label_upper_right => text.align_right
        => text.align_center

get_label_bg_color(LabelStyle lbl_style, color lbl_color) =>
    switch lbl_style
        LabelStyle.none => na
        => color.new(lbl_color, i_label_bg_transparency)

get_label_text_color(LabelStyle lbl_style, color lbl_color) =>
    switch lbl_style
        LabelStyle.none => lbl_color
        => i_label_text_color

get_label_size(LabelSize lbl_size) =>
    switch lbl_size
        LabelSize.auto => size.auto
        LabelSize.tiny => size.tiny
        LabelSize.small => size.small
        LabelSize.normal => size.normal
        LabelSize.large => size.large
        LabelSize.huge => size.huge
        => size.auto

get_line_style(LineStyle line_style) =>
    switch line_style
        LineStyle.solid => line.style_solid
        LineStyle.dashed => line.style_dashed
        LineStyle.dotted => line.style_dotted
        => line.style_solid

update_line_and_label(bool enabled, line ln, label lbl, int line_start_bar_index, string line_style, int line_width, string line_extend, float value, string name, color color, string tooltip) =>
    line result_ln = ln
    label result_lbl = lbl
    if enabled
        // Line
        string result_ln_extend = (bar_index == line_start_bar_index) ? extend.none : line_extend
        if na(result_ln)
            result_ln := line.new(math.max(line_start_bar_index, bar_index - MAX_BARS_BACK), value, bar_index, value, xloc.bar_index, result_ln_extend, color, line_style, line_width)
        if not na(result_ln)
            line.set_xy1(result_ln, math.max(line_start_bar_index, bar_index - MAX_BARS_BACK), value)
            line.set_xy2(result_ln, bar_index, value)
            line.set_extend(result_ln, result_ln_extend)
        // Label (optional)
        if i_show_labels
            string result_lbl_text = str.tostring(value, price_format) + " " + name
            if na(result_lbl)
                result_lbl := label.new(bar_index + i_label_offset, value, result_lbl_text, xloc.bar_index, yloc.price, get_label_bg_color(i_label_style, color), get_label_style(i_label_style), get_label_text_color(i_label_style, color), get_label_size(i_label_size), get_label_textalign(i_label_style), tooltip)
            if not na(result_lbl)
                label.set_xy(result_lbl, bar_index + i_label_offset, value)
                label.set_text(result_lbl, result_lbl_text)
    [result_ln, result_lbl]


////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////////////////////////

once not initialized
    price_format := "0"
    string mintick_str = str.tostring(syminfo.mintick)
    int period_pos = str.pos(mintick_str, ".")
    if not na(period_pos)
        price_format := price_format + "."
        int decimal_place = (str.length(mintick_str) - period_pos) - 1
        for i = 1 to decimal_place by 1
            price_format := price_format + "0"
    log.info("PRICE FORMAT: " + price_format)
    [eth_start_time_tmp, eth_end_time_tmp] = LunarTick.get_session_times(i_eth_session)
    eth_start_time_hhmm := eth_start_time_tmp
    eth_end_time_hhmm := eth_end_time_tmp
    [rth_start_time_tmp, rth_end_time_tmp] = LunarTick.get_session_times(i_rth_session)
    rth_start_time_hhmm := rth_start_time_tmp
    rth_end_time_hhmm := rth_end_time_tmp
    log.info("ETH start time: " + str.tostring(eth_start_time_hhmm))
    log.info("ETH end time: " + str.tostring(eth_end_time_hhmm))
    log.info("RTH start time: " + str.tostring(rth_start_time_hhmm))
    log.info("RTH end time: " + str.tostring(rth_end_time_hhmm))
    initialized := true


////////////////////////////////////////////////////////////////////////////////////////////////////
// Session Background
////////////////////////////////////////////////////////////////////////////////////////////////////

color bg_color = (not na(time("", i_eth_session, i_timezone)) and na(time("", i_rth_session, i_timezone))) ? i_eth_bg_color : na
bgcolor(bg_color)


////////////////////////////////////////////////////////////////////////////////////////////////////
// Real Open/High/Low/Close (in case we are on a Heikin Ashi chart)
////////////////////////////////////////////////////////////////////////////////////////////////////

[real_open, real_high, real_low, real_close] = request.security(ticker.standard(syminfo.tickerid), timeframe.period, [open, high, low, close])


////////////////////////////////////////////////////////////////////////////////////////////////////
// Opening Print
////////////////////////////////////////////////////////////////////////////////////////////////////

var float op = na
var int op_bar_index = na
var line op_line = na
var label op_label = na

if barstate.isnew and (LunarTick.get_bar_time_hhmm(1, i_timezone) < rth_start_time_hhmm) and (LunarTick.get_bar_time_hhmm(0, i_timezone) == rth_start_time_hhmm)
    // New RTH session started
    op := real_open
    op_bar_index := bar_index

[op_line_tmp, op_label_tmp] = update_line_and_label(i_op_enabled and can_show_timeframe("D"), op_line, op_label, op_bar_index, get_line_style(i_op_line_style), i_op_line_width, extend.right, op, "OP", i_op_color, "Opening Print")
op_line := op_line_tmp
op_label := op_label_tmp


////////////////////////////////////////////////////////////////////////////////////////////////////
// Previous Daily High/Low
////////////////////////////////////////////////////////////////////////////////////////////////////

var float cdh = na
var int cdh_bar_index = na
var float pdh = na
var int pdh_bar_index = na
var line pdh_line = na
var label pdh_label = na

var float cdl = na
var int cdl_bar_index = na
var float pdl = na
var int pdl_bar_index = na
var line pdl_line = na
var label pdl_label = na

if barstate.isnew and (LunarTick.get_bar_time_hhmm(1, i_timezone) < rth_start_time_hhmm) and (LunarTick.get_bar_time_hhmm(0, i_timezone) == rth_start_time_hhmm)
    // New RTH session started
    cdh := real_high
    cdh_bar_index := bar_index
    cdl := real_low
    cdl_bar_index := bar_index

if barstate.isnew and na(time("", i_rth_session, i_timezone)) and not na(time("", i_rth_session, i_timezone, 1))
    // Just left RTH session
    pdh := cdh
    pdh_bar_index := cdh_bar_index
    pdl := cdl
    pdl_bar_index := cdl_bar_index

if not na(time("", i_rth_session, i_timezone))
    if real_high > cdh
        cdh := real_high
        cdh_bar_index := bar_index
    if real_low < cdl
        cdl := real_low
        cdl_bar_index := bar_index

[pdh_line_tmp, pdh_label_tmp] = update_line_and_label(i_pdh_enabled and can_show_timeframe("D"), pdh_line, pdh_label, pdh_bar_index, get_line_style(i_pdh_line_style), i_pdh_line_width, extend.right, pdh, "PDH", i_pdh_color, "Previous Daily High")
pdh_line := pdh_line_tmp
pdh_label := pdh_label_tmp
[pdl_line_tmp, pdl_label_tmp] = update_line_and_label(i_pdl_enabled and can_show_timeframe("D"), pdl_line, pdl_label, pdl_bar_index, get_line_style(i_pdl_line_style), i_pdl_line_width, extend.right, pdl, "PDL", i_pdl_color, "Previous Daily Low")
pdl_line := pdl_line_tmp
pdl_label := pdl_label_tmp


////////////////////////////////////////////////////////////////////////////////////////////////////
// Overnight High/Low
////////////////////////////////////////////////////////////////////////////////////////////////////

var float conh = na
var int conh_bar_index = na
var float ponh = na
var int ponh_bar_index = na
var line ponh_line = na
var label ponh_label = na

var float conl = na
var int conl_bar_index = na
var float ponl = na
var int ponl_bar_index = na
var line ponl_line = na
var label ponl_label = na

if barstate.isnew and (LunarTick.get_bar_time_hhmm(1, i_timezone) < eth_start_time_hhmm) and (LunarTick.get_bar_time_hhmm(0, i_timezone) == eth_start_time_hhmm)
    // New ETH session started
    conh := real_high
    conh_bar_index := bar_index
    conl := real_low
    conl_bar_index := bar_index

if barstate.isnew and (not na(time("", i_eth_session, i_timezone))) and (not na(time("", i_rth_session, i_timezone))) and na(time("", i_rth_session, i_timezone, 1))
    // Just entered RTH session
    ponh := conh
    ponh_bar_index := conh_bar_index
    ponl := conl
    ponl_bar_index := conl_bar_index

if not na(time("", i_eth_session, i_timezone)) and na(time("", i_rth_session, i_timezone))
    if real_high > conh
        conh := real_high
        conh_bar_index := bar_index
    if real_low < conl
        conl := real_low
        conl_bar_index := bar_index

[ponh_line_tmp, ponh_label_tmp] = update_line_and_label(i_onh_enabled and can_show_timeframe("D"), ponh_line, ponh_label, ponh_bar_index, get_line_style(i_onh_line_style), i_onh_line_width, extend.right, ponh, "ONH", i_onh_color, "Overnight High")
ponh_line := ponh_line_tmp
ponh_label := ponh_label_tmp
[ponl_line_tmp, ponl_label_tmp] = update_line_and_label(i_onl_enabled and can_show_timeframe("D"), ponl_line, ponl_label, ponl_bar_index, get_line_style(i_onl_line_style), i_onl_line_width, extend.right, ponl, "ONL", i_onl_color, "Overnight Low")
ponl_line := ponl_line_tmp
ponl_label := ponl_label_tmp


////////////////////////////////////////////////////////////////////////////////////////////////////
// 1H Moving-Averages
////////////////////////////////////////////////////////////////////////////////////////////////////

[sma1_1h_value, sma2_1h_value, sma3_1h_value, sma4_1h_value] = request.security(ticker.standard(syminfo.tickerid), "60", [ta.sma(close, i_sma1_1h_length), ta.sma(close, i_sma2_1h_length), ta.sma(close, i_sma3_1h_length), ta.sma(close, i_sma4_1h_length)])

var line sma1_1h_line = na
var line sma2_1h_line = na
var line sma3_1h_line = na
var line sma4_1h_line = na
var label sma1_1h_label = na
var label sma2_1h_label = na
var label sma3_1h_label = na
var label sma4_1h_label = na

[sma1_1h_line_tmp, sma1_1h_label_tmp] = update_line_and_label(i_sma1_1h_enabled and can_show_timeframe("60"), sma1_1h_line, sma1_1h_label, bar_index - 1, get_line_style(i_sma1_1h_line_style), i_sma1_1h_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma1_1h_value, "1H " + str.tostring(i_sma1_1h_length), i_sma1_1h_color, "1H " + str.tostring(i_sma1_1h_length) + " SMA")
[sma2_1h_line_tmp, sma2_1h_label_tmp] = update_line_and_label(i_sma2_1h_enabled and can_show_timeframe("60"), sma2_1h_line, sma2_1h_label, bar_index - 1, get_line_style(i_sma2_1h_line_style), i_sma2_1h_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma2_1h_value, "1H " + str.tostring(i_sma2_1h_length), i_sma2_1h_color, "1H " + str.tostring(i_sma2_1h_length) + " SMA")
[sma3_1h_line_tmp, sma3_1h_label_tmp] = update_line_and_label(i_sma3_1h_enabled and can_show_timeframe("60"), sma3_1h_line, sma3_1h_label, bar_index - 1, get_line_style(i_sma3_1h_line_style), i_sma3_1h_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma3_1h_value, "1H " + str.tostring(i_sma3_1h_length), i_sma3_1h_color, "1H " + str.tostring(i_sma3_1h_length) + " SMA")
[sma4_1h_line_tmp, sma4_1h_label_tmp] = update_line_and_label(i_sma4_1h_enabled and can_show_timeframe("60"), sma4_1h_line, sma4_1h_label, bar_index - 1, get_line_style(i_sma4_1h_line_style), i_sma4_1h_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma4_1h_value, "1H " + str.tostring(i_sma4_1h_length), i_sma4_1h_color, "1H " + str.tostring(i_sma4_1h_length) + " SMA")

sma1_1h_line := sma1_1h_line_tmp
sma2_1h_line := sma2_1h_line_tmp
sma3_1h_line := sma3_1h_line_tmp
sma4_1h_line := sma4_1h_line_tmp
sma1_1h_label := sma1_1h_label_tmp
sma2_1h_label := sma2_1h_label_tmp
sma3_1h_label := sma3_1h_label_tmp
sma4_1h_label := sma4_1h_label_tmp


////////////////////////////////////////////////////////////////////////////////////////////////////
// 4H Moving-Averages
////////////////////////////////////////////////////////////////////////////////////////////////////

[sma1_4h_value, sma2_4h_value, sma3_4h_value, sma4_4h_value] = request.security(ticker.standard(syminfo.tickerid), "240", [ta.sma(close, i_sma1_4h_length), ta.sma(close, i_sma2_4h_length), ta.sma(close, i_sma3_4h_length), ta.sma(close, i_sma4_4h_length)])

var line sma1_4h_line = na
var line sma2_4h_line = na
var line sma3_4h_line = na
var line sma4_4h_line = na
var label sma1_4h_label = na
var label sma2_4h_label = na
var label sma3_4h_label = na
var label sma4_4h_label = na

[sma1_4h_line_tmp, sma1_4h_label_tmp] = update_line_and_label(i_sma1_4h_enabled and can_show_timeframe("240"), sma1_4h_line, sma1_4h_label, bar_index - 1, get_line_style(i_sma1_4h_line_style), i_sma1_4h_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma1_4h_value, "4H " + str.tostring(i_sma1_4h_length), i_sma1_4h_color, "4H " + str.tostring(i_sma1_4h_length) + " SMA")
[sma2_4h_line_tmp, sma2_4h_label_tmp] = update_line_and_label(i_sma2_4h_enabled and can_show_timeframe("240"), sma2_4h_line, sma2_4h_label, bar_index - 1, get_line_style(i_sma2_4h_line_style), i_sma2_4h_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma2_4h_value, "4H " + str.tostring(i_sma2_4h_length), i_sma2_4h_color, "4H " + str.tostring(i_sma2_4h_length) + " SMA")
[sma3_4h_line_tmp, sma3_4h_label_tmp] = update_line_and_label(i_sma3_4h_enabled and can_show_timeframe("240"), sma3_4h_line, sma3_4h_label, bar_index - 1, get_line_style(i_sma3_4h_line_style), i_sma3_4h_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma3_4h_value, "4H " + str.tostring(i_sma3_4h_length), i_sma3_4h_color, "4H " + str.tostring(i_sma3_4h_length) + " SMA")
[sma4_4h_line_tmp, sma4_4h_label_tmp] = update_line_and_label(i_sma4_4h_enabled and can_show_timeframe("240"), sma4_4h_line, sma4_4h_label, bar_index - 1, get_line_style(i_sma4_4h_line_style), i_sma4_4h_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma4_4h_value, "4H " + str.tostring(i_sma4_4h_length), i_sma4_4h_color, "4H " + str.tostring(i_sma4_4h_length) + " SMA")

sma1_4h_line := sma1_4h_line_tmp
sma2_4h_line := sma2_4h_line_tmp
sma3_4h_line := sma3_4h_line_tmp
sma4_4h_line := sma4_4h_line_tmp
sma1_4h_label := sma1_4h_label_tmp
sma2_4h_label := sma2_4h_label_tmp
sma3_4h_label := sma3_4h_label_tmp
sma4_4h_label := sma4_4h_label_tmp


////////////////////////////////////////////////////////////////////////////////////////////////////
// Daily Moving-Averages
////////////////////////////////////////////////////////////////////////////////////////////////////

[sma1_d_value, sma2_d_value, sma3_d_value, sma4_d_value] = request.security(ticker.standard(syminfo.tickerid), "D", [ta.sma(close, i_sma1_d_length), ta.sma(close, i_sma2_d_length), ta.sma(close, i_sma3_d_length), ta.sma(close, i_sma4_d_length)])

var line sma1_d_line = na
var line sma2_d_line = na
var line sma3_d_line = na
var line sma4_d_line = na
var label sma1_d_label = na
var label sma2_d_label = na
var label sma3_d_label = na
var label sma4_d_label = na

[sma1_d_line_tmp, sma1_d_label_tmp] = update_line_and_label(i_sma1_d_enabled and can_show_timeframe("D"), sma1_d_line, sma1_d_label, bar_index - 1, get_line_style(i_sma1_d_line_style), i_sma1_d_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma1_d_value, "D " + str.tostring(i_sma1_d_length), i_sma1_d_color, "D " + str.tostring(i_sma1_d_length) + " SMA")
[sma2_d_line_tmp, sma2_d_label_tmp] = update_line_and_label(i_sma2_d_enabled and can_show_timeframe("D"), sma2_d_line, sma2_d_label, bar_index - 1, get_line_style(i_sma2_d_line_style), i_sma2_d_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma2_d_value, "D " + str.tostring(i_sma2_d_length), i_sma2_d_color, "D " + str.tostring(i_sma2_d_length) + " SMA")
[sma3_d_line_tmp, sma3_d_label_tmp] = update_line_and_label(i_sma3_d_enabled and can_show_timeframe("D"), sma3_d_line, sma3_d_label, bar_index - 1, get_line_style(i_sma3_d_line_style), i_sma3_d_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma3_d_value, "D " + str.tostring(i_sma3_d_length), i_sma3_d_color, "D " + str.tostring(i_sma3_d_length) + " SMA")
[sma4_d_line_tmp, sma4_d_label_tmp] = update_line_and_label(i_sma4_d_enabled and can_show_timeframe("D"), sma4_d_line, sma4_d_label, bar_index - 1, get_line_style(i_sma4_d_line_style), i_sma4_d_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma4_d_value, "D " + str.tostring(i_sma4_d_length), i_sma4_d_color, "D " + str.tostring(i_sma4_d_length) + " SMA")

sma1_d_line := sma1_d_line_tmp
sma2_d_line := sma2_d_line_tmp
sma3_d_line := sma3_d_line_tmp
sma4_d_line := sma4_d_line_tmp
sma1_d_label := sma1_d_label_tmp
sma2_d_label := sma2_d_label_tmp
sma3_d_label := sma3_d_label_tmp
sma4_d_label := sma4_d_label_tmp


////////////////////////////////////////////////////////////////////////////////////////////////////
// Weekly Moving-Averages
////////////////////////////////////////////////////////////////////////////////////////////////////

[sma1_w_value, sma2_w_value, sma3_w_value, sma4_w_value] = request.security(ticker.standard(syminfo.tickerid), "W", [ta.sma(close, i_sma1_w_length), ta.sma(close, i_sma2_w_length), ta.sma(close, i_sma3_w_length), ta.sma(close, i_sma4_w_length)])

var line sma1_w_line = na
var line sma2_w_line = na
var line sma3_w_line = na
var line sma4_w_line = na
var label sma1_w_label = na
var label sma2_w_label = na
var label sma3_w_label = na
var label sma4_w_label = na

[sma1_w_line_tmp, sma1_w_label_tmp] = update_line_and_label(i_sma1_w_enabled and can_show_timeframe("W"), sma1_w_line, sma1_w_label, bar_index - 1, get_line_style(i_sma1_w_line_style), i_sma1_w_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma1_w_value, "W " + str.tostring(i_sma1_w_length), i_sma1_w_color, "W " + str.tostring(i_sma1_w_length) + " SMA")
[sma2_w_line_tmp, sma2_w_label_tmp] = update_line_and_label(i_sma2_w_enabled and can_show_timeframe("W"), sma2_w_line, sma2_w_label, bar_index - 1, get_line_style(i_sma2_w_line_style), i_sma2_w_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma2_w_value, "W " + str.tostring(i_sma2_w_length), i_sma2_w_color, "W " + str.tostring(i_sma2_w_length) + " SMA")
[sma3_w_line_tmp, sma3_w_label_tmp] = update_line_and_label(i_sma3_w_enabled and can_show_timeframe("W"), sma3_w_line, sma3_w_label, bar_index - 1, get_line_style(i_sma3_w_line_style), i_sma3_w_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma3_w_value, "W " + str.tostring(i_sma3_w_length), i_sma3_w_color, "W " + str.tostring(i_sma3_w_length) + " SMA")
[sma4_w_line_tmp, sma4_w_label_tmp] = update_line_and_label(i_sma4_w_enabled and can_show_timeframe("W"), sma4_w_line, sma4_w_label, bar_index - 1, get_line_style(i_sma4_w_line_style), i_sma4_w_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma4_w_value, "W " + str.tostring(i_sma4_w_length), i_sma4_w_color, "W " + str.tostring(i_sma4_w_length) + " SMA")

sma1_w_line := sma1_w_line_tmp
sma2_w_line := sma2_w_line_tmp
sma3_w_line := sma3_w_line_tmp
sma4_w_line := sma4_w_line_tmp
sma1_w_label := sma1_w_label_tmp
sma2_w_label := sma2_w_label_tmp
sma3_w_label := sma3_w_label_tmp
sma4_w_label := sma4_w_label_tmp


////////////////////////////////////////////////////////////////////////////////////////////////////
// Monthly Moving-Averages
////////////////////////////////////////////////////////////////////////////////////////////////////

[sma1_m_value, sma2_m_value, sma3_m_value, sma4_m_value] = request.security(ticker.standard(syminfo.tickerid), "M", [ta.sma(close, i_sma1_m_length), ta.sma(close, i_sma2_m_length), ta.sma(close, i_sma3_m_length), ta.sma(close, i_sma4_m_length)])

var line sma1_m_line = na
var line sma2_m_line = na
var line sma3_m_line = na
var line sma4_m_line = na
var label sma1_m_label = na
var label sma2_m_label = na
var label sma3_m_label = na
var label sma4_m_label = na

[sma1_m_line_tmp, sma1_m_label_tmp] = update_line_and_label(i_sma1_m_enabled and can_show_timeframe("M"), sma1_m_line, sma1_m_label, bar_index - 1, get_line_style(i_sma1_m_line_style), i_sma1_m_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma1_m_value, "M " + str.tostring(i_sma1_m_length), i_sma1_m_color, "M " + str.tostring(i_sma1_m_length) + " SMA")
[sma2_m_line_tmp, sma2_m_label_tmp] = update_line_and_label(i_sma2_m_enabled and can_show_timeframe("M"), sma2_m_line, sma2_m_label, bar_index - 1, get_line_style(i_sma2_m_line_style), i_sma2_m_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma2_m_value, "M " + str.tostring(i_sma2_m_length), i_sma2_m_color, "M " + str.tostring(i_sma2_m_length) + " SMA")
[sma3_m_line_tmp, sma3_m_label_tmp] = update_line_and_label(i_sma3_m_enabled and can_show_timeframe("M"), sma3_m_line, sma3_m_label, bar_index - 1, get_line_style(i_sma3_m_line_style), i_sma3_m_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma3_m_value, "M " + str.tostring(i_sma3_m_length), i_sma3_m_color, "M " + str.tostring(i_sma3_m_length) + " SMA")
[sma4_m_line_tmp, sma4_m_label_tmp] = update_line_and_label(i_sma4_m_enabled and can_show_timeframe("M"), sma4_m_line, sma4_m_label, bar_index - 1, get_line_style(i_sma4_m_line_style), i_sma4_m_line_width, (i_extend_sma_levels ? extend.both : extend.right), sma4_m_value, "M " + str.tostring(i_sma4_m_length), i_sma4_m_color, "M " + str.tostring(i_sma4_m_length) + " SMA")

sma1_m_line := sma1_m_line_tmp
sma2_m_line := sma2_m_line_tmp
sma3_m_line := sma3_m_line_tmp
sma4_m_line := sma4_m_line_tmp
sma1_m_label := sma1_m_label_tmp
sma2_m_label := sma2_m_label_tmp
sma3_m_label := sma3_m_label_tmp
sma4_m_label := sma4_m_label_tmp

Overview

LunarTick Levels highlights key price points including the Opening Print, Previous Day High and Low, and Overnight High and Low. Additionally, it projects higher timeframe SMAs ranging from 1-hour up to monthly intervals. Inputs allow users to toggle specific levels, adjust colors, modify line styles, change widths, and configure moving average periods.

Details

Published by

lunarticktrading on GitHub

Code credit

gambcl, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance, Moving averages, Sessions & time

Markets

Any symbol

Timeframes

M1-M5, M15-H1, H4 and above

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
OPbooltruei_op_enabled
i_op_colorcolorcolor.purplei_op_color
i_op_line_styleenumLineStyle.dashedi_op_line_style
i_op_line_widthint2i_op_line_width
PDHbooltruei_pdh_enabled
i_pdh_colorcolorcolor.redi_pdh_color
i_pdh_line_styleenumLineStyle.dashedi_pdh_line_style
i_pdh_line_widthint2i_pdh_line_width
PDLbooltruei_pdl_enabled
i_pdl_colorcolorcolor.greeni_pdl_color
i_pdl_line_styleenumLineStyle.dashedi_pdl_line_style
i_pdl_line_widthint2i_pdl_line_width
Show all 40 settings
SettingTypeDefaultVariable
ONHbooltruei_onh_enabled
i_onh_colorcolorcolor.grayi_onh_color
i_onh_line_styleenumLineStyle.dashedi_onh_line_style
i_onh_line_widthint2i_onh_line_width
ONLbooltruei_onl_enabled
i_onl_colorcolorcolor.grayi_onl_color
i_onl_line_styleenumLineStyle.dashedi_onl_line_style
i_onl_line_widthint2i_onl_line_width
i_sma1_1h_enabledboolfalsei_sma1_1h_enabled
i_sma1_1h_lengthint20i_sma1_1h_length
i_sma1_1h_colorcolorcolor.fuchsiai_sma1_1h_color
i_sma1_1h_line_styleenumLineStyle.solidi_sma1_1h_line_style
i_sma1_1h_line_widthint1i_sma1_1h_line_width
i_sma2_1h_enabledbooltruei_sma2_1h_enabled
i_sma2_1h_lengthint50i_sma2_1h_length
i_sma2_1h_colorcolorcolor.fuchsiai_sma2_1h_color
i_sma2_1h_line_styleenumLineStyle.solidi_sma2_1h_line_style
i_sma2_1h_line_widthint1i_sma2_1h_line_width
i_sma3_1h_enabledbooltruei_sma3_1h_enabled
i_sma3_1h_lengthint100i_sma3_1h_length
i_sma3_1h_colorcolorcolor.fuchsiai_sma3_1h_color
i_sma3_1h_line_styleenumLineStyle.solidi_sma3_1h_line_style
i_sma3_1h_line_widthint1i_sma3_1h_line_width
i_sma4_1h_enabledbooltruei_sma4_1h_enabled
i_sma4_1h_lengthint200i_sma4_1h_length
i_sma4_1h_colorcolorcolor.fuchsiai_sma4_1h_color
i_sma4_1h_line_styleenumLineStyle.solidi_sma4_1h_line_style
i_sma4_1h_line_widthint1i_sma4_1h_line_width
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Midnight VWAP

by TradersPost
218 stars

The Midnight VWAP indicator calculates and overlays two distinct Volume Weighted Average Price (VWAP) lines on the price chart based on customizable session timeframes. It tracks an overnight or pre-market session alongside regular trading hours, resetting cal

Indicator v6 Moving averagesSessions & time
Updated 3 months ago · None stated GitHub repository of Midnight VWAP

Moon Dev GEX Walls & Trap

by moondevonyt
92 stars

This indicator estimates gamma exposure levels and intraday context for index instruments like SPY and ES. It calculates VWAP with standard deviation bands as a gamma flip proxy, highlighting market regimes through background colors. It plots prior day high, l

Indicator v5 Support & resistanceSessions & time
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev GEX Walls & Trap

PA Indicators

by forecho
5 stars

This indicator plots price action tools directly on the main price chart. It shades candles according to Internal Bar Strength (IBS) and optional wick-length thresholds to differentiate trend bars from trading ranges. The script tracks session bar counts durin

Indicator v6 Candlestick patternsMoving averages
Updated 8 weeks ago · None stated GitHub repository of PA Indicators

TradeKit

by tanishq-rocks
5 stars

TradeKit is an all-in-one technical analysis indicator that consolidates multiple chart overlays into a single script on the price chart. It plots up to four customizable moving averages (SMA, EMA, SMMA, WMA, or VWMA), Bollinger Bands, VWAP, and reference leve

Indicator v6 Moving averagesCandlestick patterns
Updated 3 months ago · MPL-2.0 GitHub repository of TradeKit
948 stars

Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us

Indicator v4 Moving averagesSupport & resistance
Updated 10 days ago · GPL-3.0 GitHub repository of Moving Average Channel
575 stars

This indicator builds Market Profile Time Price Opportunity (TPO) structures across defined session timeframes directly on the main price chart. It visualizes the Point of Control (POC) and Value Area boundaries using dynamic box drawings. An integrated multi-

Indicator v5 Support & resistanceScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of Market Profile with Screener

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers