本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Linear GANN 2.0 - SEHAJ WEALTH MANAGEMENT", overlay=true, max_lines_count=500, max_labels_count=500)
// Input options for customization
lineColor = input.color(color.purple, "Line Color")
lineWidth = input.int(2, "Line Width", minval=1, maxval=5)
showLabels = input.bool(true, "Show Price Labels") // Toggle for labels
// Define all price levels
var float[] levels = array.from(
1.0, 5.0, 9.0, 17.0, 25.0, 37.0, 49.0, 65.0, 81.0, 101.0, 121.0, 145.0, 169.0, 197.0, 225.0, 257.0, 289.0, 325.0, 361.0, 401.0,
441.0, 485.0, 529.0, 577.0, 625.0, 677.0, 729.0, 785.0, 841.0, 901.0, 961.0, 1025.0, 1089.0, 1157.0, 1225.0, 1297.0, 1369.0, 1445.0, 1521.0, 1601.0,
1681.0, 1765.0, 1849.0, 1937.0, 2025.0, 2117.0, 2209.0, 2305.0, 2401.0, 2501.0, 2601.0, 2705.0, 2809.0, 2917.0, 3025.0, 3137.0, 3249.0, 3365.0, 3481.0, 3601.0,
3721.0, 3845.0, 3969.0, 4097.0, 4225.0, 4357.0, 4489.0, 4625.0, 4761.0, 4901.0, 5041.0, 5185.0, 5329.0, 5477.0, 5625.0, 5777.0, 5929.0, 6085.0, 6241.0, 6401.0,
6561.0, 6725.0, 6889.0, 7057.0, 7225.0, 7397.0, 7569.0, 7745.0, 7921.0, 8101.0, 8281.0, 8465.0, 8649.0, 8837.0, 9025.0, 9217.0, 9409.0, 9605.0, 9801.0, 10001.0,
10201.0, 10405.0, 10609.0, 10817.0, 11025.0, 11237.0, 11449.0, 11665.0, 11881.0, 12101.0, 12321.0, 12545.0, 12769.0, 12997.0, 13225.0, 13457.0, 13689.0, 13925.0, 14161.0, 14401.0,
14641.0, 14885.0, 15129.0, 15377.0, 15625.0, 15877.0, 16129.0, 16385.0, 16641.0, 16901.0, 17161.0, 17425.0, 17689.0, 17957.0, 18225.0, 18497.0, 18769.0, 19045.0, 19321.0, 19601.0,
19881.0, 20165.0, 20449.0, 20737.0, 21025.0, 21317.0, 21609.0, 21905.0, 22201.0, 22501.0, 22801.0, 23105.0, 23409.0, 23717.0, 24025.0, 24337.0, 24649.0, 24965.0, 25281.0, 25601.0,
25921.0, 26245.0, 26569.0, 26897.0, 27225.0, 27557.0, 27889.0, 28225.0, 28561.0, 28901.0, 29241.0, 29585.0, 29929.0, 30277.0, 30625.0, 30977.0, 31329.0, 31685.0, 32041.0, 32401.0,
32761.0, 33125.0, 33489.0, 33857.0, 34225.0, 34597.0, 34969.0, 35345.0, 35721.0, 36101.0, 36481.0, 36865.0, 37249.0, 37637.0, 38025.0, 38417.0, 38809.0, 39205.0, 39601.0, 40001.0,
40401.0, 40805.0, 41209.0, 41617.0, 42025.0, 42437.0, 42849.0, 43265.0, 43681.0, 44101.0, 44521.0, 44945.0, 45369.0, 45797.0, 46225.0, 46657.0, 47089.0, 47525.0, 47961.0, 48401.0,
48841.0, 49285.0, 49729.0, 50177.0, 50625.0, 51077.0, 51529.0, 51985.0, 52441.0, 52901.0, 53361.0, 53825.0, 54289.0, 54757.0, 55225.0, 55697.0, 56169.0, 56645.0, 57121.0, 57601.0,
58081.0, 58565.0, 59049.0, 59537.0, 60025.0, 60517.0, 61009.0, 61505.0, 62001.0, 62501.0, 63001.0, 63505.0, 64009.0, 64517.0, 65025.0, 65537.0, 66049.0, 66565.0, 67081.0, 67601.0,
68121.0, 68645.0, 69169.0, 69697.0, 70225.0, 70757.0, 71289.0, 71825.0, 72361.0, 72901.0, 73441.0, 73985.0, 74529.0, 75077.0, 75625.0, 76177.0, 76729.0, 77285.0, 77841.0, 78401.0,
78961.0, 79525.0, 80089.0, 80657.0, 81225.0, 81797.0, 82369.0, 82945.0, 83521.0, 84101.0, 84681.0, 85265.0, 85849.0, 86437.0, 87025.0, 87617.0, 88209.0, 88805.0, 89401.0, 90001.0,
90601.0, 91205.0, 91809.0, 92417.0, 93025.0, 93637.0, 94249.0, 94865.0, 95481.0, 96101.0, 96721.0, 97345.0, 97969.0, 98597.0, 99225.0, 99857.0, 100489.0, 101125.0, 101761.0, 102401.0,
103041.0, 103685.0, 104329.0, 104977.0, 105625.0, 106277.0, 106929.0, 107585.0, 108241.0, 108901.0, 109561.0, 110225.0, 110889.0, 111557.0, 112225.0, 112897.0, 113569.0, 114245.0, 114921.0, 115601.0,
116281.0, 116965.0, 117649.0, 118337.0, 119025.0, 119717.0, 120409.0, 121105.0, 121801.0, 122501.0, 123201.0, 123905.0, 124609.0, 125317.0, 126025.0, 126737.0, 127449.0, 128165.0, 128881.0, 129601.0,
130321.0, 131045.0, 131769.0, 132497.0, 133225.0, 133957.0, 134689.0, 135425.0, 136161.0, 136901.0, 137641.0, 138385.0, 139129.0, 139877.0, 140625.0, 141377.0, 142129.0, 142885.0, 143641.0, 144401.0,
145161.0, 145925.0, 146689.0, 147457.0, 148225.0, 148997.0, 149769.0, 150545.0, 151321.0, 152101.0, 152881.0, 153665.0, 154449.0, 155237.0, 156025.0, 156817.0, 157609.0, 158405.0, 159201.0, 160001.0,
160801.0, 161605.0, 162409.0, 163217.0, 164025.0, 164837.0, 165649.0, 166465.0, 167281.0, 168101.0, 168921.0, 169745.0, 170569.0, 171397.0, 172225.0, 173057.0, 173889.0, 174725.0, 175561.0, 176401.0,
177241.0, 178085.0, 178929.0, 179777.0, 180625.0, 181477.0, 182329.0, 183185.0, 184041.0, 184901.0, 185761.0, 186625.0, 187489.0, 188357.0, 189225.0, 190097.0, 190969.0, 191845.0, 192721.0, 193601.0,
194481.0, 195365.0, 196249.0, 197137.0, 198025.0, 198917.0, 199809.0, 200705.0)
// Array to store our dynamically generated labels
var label[] priceLabels = array.new_label()
// Create lines and initialize labels on the very first bar
if bar_index == 0
for i = 0 to array.size(levels) - 1
level = array.get(levels, i)
// Draw the horizontal line
line.new(bar_index, level, bar_index + 1, level, extend=extend.both, color=lineColor, width=lineWidth)
// Initialize the label on the line (set to transparent background for a clean look)
if showLabels
lbl = label.new(x=bar_index, y=level, text=str.tostring(level),
style=label.style_none, color=color.new(color.white, 100),
textcolor=lineColor, size=size.large)
array.push(priceLabels, lbl)
// Update the label positions to always sit on the right-most edge of the chart (mimicking scale labels)
if barstate.islast and showLabels
for i = 0 to array.size(priceLabels) - 1
// Shift the label's X position to the current last bar (plus a small offset into the future margin)
label.set_x(array.get(priceLabels, i), bar_index + 15)