vvk

Wait 5 sec.

vvkTata Motors Passenger Vehicles LtdNSE:TMPVkmsivakrish//@version=5 indicator("Equator System - Lines & Labels", overlay=true) // ========================================== // SYMBOL LOGIC & STRIKE EXTRACTION // ========================================== var string symbol_atmcall = na var string symbol_atmput = na symbol_strike = syminfo.ticker last_6_digits = str.substring(symbol_strike, str.length(symbol_strike) - 6, str.length(symbol_strike)) first_char = str.substring(last_6_digits, 0, 1) is_call = (first_char == "C") if is_call symbol_atmcall := symbol_strike new_last_6_digits = str.replace(last_6_digits, "C", "P") symbol_atmput := str.replace(symbol_atmcall, last_6_digits, new_last_6_digits) else if first_char == "P" symbol_atmput := symbol_strike new_last_6_digits = str.replace(last_6_digits, "P", "C") symbol_atmcall := str.replace(symbol_atmput, last_6_digits, new_last_6_digits) last_5_digits_call = str.substring(symbol_atmcall, str.length(symbol_atmcall) - 5, str.length(symbol_atmcall)) last_5_digits_put = str.substring(symbol_atmput, str.length(symbol_atmput) - 5, str.length(symbol_atmput)) call_strike = str.tonumber(last_5_digits_call) put_strike = str.tonumber(last_5_digits_put) // ========================================== // USER INPUTS // ========================================== grp_display = "Display Settings" display_mode = input.string("Auto (Chart Symbol)", title="Display Line Mode", options=, group=grp_display, tooltip="Auto shows CE lines if on CE chart, PE lines if on PE chart.") plot_lines = input.bool(true, title="Plot Level Lines on Chart", group=grp_display) show_labels = input.bool(true, title="Show Text Labels on Lines", group=grp_display) grp_ce = "Call Option (CE) Setup" ce_ticker_input = input.symbol("NSE:NIFTY260811C24550", title="CE Option Symbol Override", group=grp_ce, tooltip="Leave unused if using Auto-Extracted chart symbol") use_ce_auto = input.bool(true, title="Auto-Detect CE Symbol from Chart?", group=grp_ce) use_ce_manual = input.bool(false, title="Use Manual CE Inputs?", group=grp_ce) ce_manual_h = input.float(150.0, title="CE Manual High (1st 5-min)", group=grp_ce) ce_manual_l = input.float(100.0, title="CE Manual Low (1st 5-min)", group=grp_ce) ce_manual_c = input.float(140.0, title="CE Manual Close (1st 5-min)", group=grp_ce) grp_pe = "Put Option (PE) Setup" pe_ticker_input = input.symbol("NSE:NIFTY260811P24750", title="PE Option Symbol Override", group=grp_pe, tooltip="Leave unused if using Auto-Extracted chart symbol") use_pe_auto = input.bool(true, title="Auto-Detect PE Symbol from Chart?", group=grp_pe) use_pe_manual = input.bool(false, title="Use Manual PE Inputs?", group=grp_pe) pe_manual_h = input.float(180.0, title="PE Manual High (1st 5-min)", group=grp_pe) pe_manual_l = input.float(120.0, title="PE Manual Low (1st 5-min)", group=grp_pe) pe_manual_c = input.float(160.0, title="PE Manual Close (1st 5-min)", group=grp_pe) // Final Tickers to Fetch final_ce_ticker = use_ce_auto ? syminfo.prefix + ":" + symbol_atmcall : ce_ticker_input final_pe_ticker = use_pe_auto ? syminfo.prefix + ":" + symbol_atmput : pe_ticker_input // Visibility Conditions for Lines and Labels show_ce_lines = plot_lines and (display_mode == "CE Only" or display_mode == "Both" or (display_mode == "Auto (Chart Symbol)" and is_call)) show_pe_lines = plot_lines and (display_mode == "PE Only" or display_mode == "Both" or (display_mode == "Auto (Chart Symbol)" and not is_call)) // ========================================== // HELPER FUNCTIONS // ========================================== extractDecimalDigits(float val) => float frac = math.abs(val - math.floor(val)) int fourDigits = math.floor(frac * 10000) fourDigits / 100.0 calcEquator(float high_val, float low_val, float close_val) => float val_D3 = high_val * (1 + 0.002611) float val_D4 = low_val * (1 - 0.002611) float val_D6 = extractDecimalDigits(val_D3) float val_D7 = extractDecimalDigits(val_D4) float f1 = high_val + val_D6 float f5 = low_val - val_D7 float val_C8 = f1 - f5 float val_D8 = val_C8 * 0.2611 float f2 = f1 - val_D8 float val_D9 = val_D8 float f4 = f5 + val_D9 float val_C10 = f2 - f4 float val_D10 = val_C10 / 2.0 float f3 = f2 - val_D10 float eq = close_val float cancer = eq + (f2 - f3) float north_p = cancer + (f1 - f2) float capricorn = eq - (f3 - f4) float south_p = capricorn - (f4 - f5) // ========================================== // FETCH OPTIONS FIRST 5-MIN HLC DATA // ========================================== int first_bar_idx = ta.valuewhen(ta.change(time("D")) != 0, bar_index, 0) ce_sec_h = request.security(final_ce_ticker, "5", high) ce_sec_l = request.security(final_ce_ticker, "5", low) ce_sec_c = request.security(final_ce_ticker, "5", close) pe_sec_h = request.security(final_pe_ticker, "5", high) pe_sec_l = request.security(final_pe_ticker, "5", low) pe_sec_c = request.security(final_pe_ticker, "5", close) final_ce_h = use_ce_manual ? ce_manual_h : ce_sec_h final_ce_l = use_ce_manual ? ce_manual_l : ce_sec_l final_ce_c = use_ce_manual ? ce_manual_c : ce_sec_c final_pe_h = use_pe_manual ? pe_manual_h : pe_sec_h final_pe_l = use_pe_manual ? pe_manual_l : pe_sec_l final_pe_c = use_pe_manual ? pe_manual_c : pe_sec_c // Execute Level Calculations = calcEquator(final_ce_h, final_ce_l, final_ce_c) = calcEquator(final_pe_h, final_pe_l, final_pe_c) // ========================================== // PLOT LINES FOR CANCER, EQUATOR, CAPRICORN // ========================================== // CE Lines plot(show_ce_lines ? ce_can : na, title="CE Cancer", color=color.teal, linewidth=2) plot(show_ce_lines ? ce_eq : na, title="CE ENTRY", color=color.orange, linewidth=2) plot(show_ce_lines ? ce_cap : na, title="CE REVERSAL", color=color.maroon, linewidth=2) // PE Lines plot(show_pe_lines ? pe_can : na, title="PE Cancer", color=color.blue, linewidth=2, style=plot.style_linebr) plot(show_pe_lines ? pe_eq : na, title="PE ENTRY", color=color.yellow, linewidth=2, style=plot.style_linebr) plot(show_pe_lines ? pe_cap : na, title="PE REVERSAL", color=color.red, linewidth=2, style=plot.style_linebr) // ========================================== // DYNAMIC TEXT LABELS ON CHART // ========================================== var label lbl_ce_can = na var label lbl_ce_eq = na var label lbl_ce_cap = na var label lbl_pe_can = na var label lbl_pe_eq = na var label lbl_pe_cap = na if barstate.islast and show_labels // Delete previous labels on update label.delete(lbl_ce_can) label.delete(lbl_ce_eq) label.delete(lbl_ce_cap) label.delete(lbl_pe_can) label.delete(lbl_pe_eq) label.delete(lbl_pe_cap) // CE Labels (Right aligned) if show_ce_lines lbl_ce_can := label.new(bar_index + 3, ce_can, "CE Cancer: " + str.tostring(ce_can, "#.00"), color=color.teal, textcolor=color.white, style=label.style_label_left) lbl_ce_eq := label.new(bar_index + 3, ce_eq, "CE ENTRY: " + str.tostring(ce_eq, "#.00"), color=color.orange, textcolor=color.white, style=label.style_label_left) lbl_ce_cap := label.new(bar_index + 3, ce_cap, "CE REVERSAL: " + str.tostring(ce_cap, "#.00"), color=color.maroon, textcolor=color.white, style=label.style_label_left) // PE Labels (Right aligned) if show_pe_lines lbl_pe_can := label.new(bar_index + 12, pe_can, "PE Cancer: " + str.tostring(pe_can, "#.00"), color=color.blue, textcolor=color.white, style=label.style_label_left) lbl_pe_eq := label.new(bar_index + 12, pe_eq, "PE ENTRY: " + str.tostring(pe_eq, "#.00"), color=color.yellow, textcolor=color.black, style=label.style_label_left) lbl_pe_cap := label.new(bar_index + 12, pe_cap, "PE REVERSAL: " + str.tostring(pe_cap, "#.00"), color=color.red, textcolor=color.white, style=label.style_label_left) // ========================================== // DISPLAY RESULTS TABLE // ========================================== var table outputTable = table.new(position.top_right, 3, 12, bgcolor=color.new(color.black, 15), border_width=1) if barstate.islast table.cell(outputTable, 0, 0, "Level / Floor", bgcolor=color.navy, text_color=color.white) table.cell(outputTable, 1, 0, final_ce_ticker, bgcolor=color.teal, text_color=color.white) table.cell(outputTable, 2, 0, final_pe_ticker, bgcolor=color.maroon, text_color=color.white) table.cell(outputTable, 0, 1, "North Pole", text_color=color.aqua) table.cell(outputTable, 1, 1, str.tostring(ce_np, "#.00"), text_color=color.white) table.cell(outputTable, 2, 1, str.tostring(pe_np, "#.00"), text_color=color.white) table.cell(outputTable, 0, 2, "Cancer", text_color=color.teal) table.cell(outputTable, 1, 2, str.tostring(ce_can, "#.00"), text_color=color.white) table.cell(outputTable, 2, 2, str.tostring(pe_can, "#.00"), text_color=color.white) table.cell(outputTable, 0, 3, "ENTRY", text_color=color.green) table.cell(outputTable, 1, 3, str.tostring(ce_eq, "#.00"), text_color=color.white) table.cell(outputTable, 2, 3, str.tostring(pe_eq, "#.00"), text_color=color.white) table.cell(outputTable, 0, 4, "REVERSAL", text_color=color.white) table.cell(outputTable, 1, 4, str.tostring(ce_cap, "#.00"), text_color=color.white) table.cell(outputTable, 2, 4, str.tostring(pe_cap, "#.00"), text_color=color.white) table.cell(outputTable, 0, 5, "South Pole", text_color=color.red) table.cell(outputTable, 1, 5, str.tostring(ce_sp, "#.00"), text_color=color.white) table.cell(outputTable, 2, 5, str.tostring(pe_sp, "#.00"), text_color=color.white) table.cell(outputTable, 0, 6, "Floor 1", text_color=color.green) table.cell(outputTable, 1, 6, str.tostring(ce_f1, "#.00"), text_color=color.white) table.cell(outputTable, 2, 6, str.tostring(pe_f1, "#.00"), text_color=color.white) table.cell(outputTable, 0, 7, "Floor 2", text_color=color.lime) table.cell(outputTable, 1, 7, str.tostring(ce_f2, "#.00"), text_color=color.white) table.cell(outputTable, 2, 7, str.tostring(pe_f2, "#.00"), text_color=color.white) table.cell(outputTable, 0, 8, "Floor 3", text_color=color.gray) table.cell(outputTable, 1, 8, str.tostring(ce_f3, "#.00"), text_color=color.white) table.cell(outputTable, 2, 8, str.tostring(pe_f3, "#.00"), text_color=color.white) table.cell(outputTable, 0, 9, "Floor 4", text_color=color.fuchsia) table.cell(outputTable, 1, 9, str.tostring(ce_f4, "#.00"), text_color=color.white) table.cell(outputTable, 2, 9, str.tostring(pe_f4, "#.00"), text_color=color.white) table.cell(outputTable, 0, 10, "Floor 5", text_color=color.red) table.cell(outputTable, 1, 10, str.tostring(ce_f5, "#.00"), text_color=color.white) table.cell(outputTable, 2, 10, str.tostring(pe_f5, "#.00"), text_color=color.white) table.cell(outputTable, 0, 11, "Extracted Strikes", bgcolor=color.navy, text_color=color.yellow) table.cell(outputTable, 1, 11, "CE Strike: " + str.tostring(call_strike), text_color=color.yellow) table.cell(outputTable, 2, 11, "PE Strike: " + str.tostring(put_strike), text_color=color.yellow)