本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Niveles clave y rango esperado", shorttitle = "Niveles clave", overlay = true, max_lines_count = 500, max_labels_count = 500)
// Key levels and expected range, computed on the data of THIS chart, with our measured frequencies next to them.
//
// What it draws
// - Prior regular session: high, low, close, midpoint, value area high / low and point of control
// (30-minute time-at-price profile, 70% value area).
// - Prior week and prior month high / low, week and month open, week-to-date high / low (regular sessions only).
// - Opening range and initial balance of the market's own day session, once each window is complete.
// - The expected move of the day and a ladder at 0.25 / 0.5 / 0.75 / 1.0 / 1.5 expected moves from the open,
// each rung with the share of past sessions that reached it. Before the open: the same ladder from the prior close.
// - A table: today's expected move, rungs reached, and what is left by the clock for the rungs not reached.
//
// What it is not: a signal. Every percentage is a frequency measured on past sessions of that market. It says how
// often a distance was travelled, not in which direction price will go, and nothing about any single day.
//
// No repainting of levels: prior-session levels are fixed when that session ends; the open, the opening range and
// the initial balance are fixed when their window is complete. Only the table (reached / left by the clock) updates
// inside the bar.
//
// Runs on TradingView charts of 1 to 60 minutes, continuous or single-contract symbols.
// --- BEGIN GENERATED CONSTANTS
// Written by scripts/build_tradingview_constants.py. Do not edit by hand.
// 29 markets, statistics through 2026-10-16. Frequencies, counts and session hours only.
string DATA_THROUGH = "2026-10-16"
f_parent(string r) =>
switch r
"MES" => "ES"
"MNQ" => "NQ"
"M2K" => "RTY"
"MYM" => "YM"
"MGC" => "GC"
"SIL" => "SI"
"MHG" => "HG"
"MCL" => "CL"
"QM" => "CL"
"MNG" => "NG"
"QG" => "NG"
"MBT" => "BTC"
"MET" => "ETH"
"M6E" => "6E"
"M6A" => "6A"
"M6B" => "6B"
"E7" => "6E"
"J7" => "6J"
"XC" => "ZC"
"XK" => "ZS"
"XW" => "ZW"
"10Y" => "ZN"
"MTN" => "ZN"
"MWN" => "ZB"
=> r
f_lvSess(string r) =>
switch r
"NKD" => "0900-1515"
=> "0930-1600"
f_lvTz(string r) =>
switch r
"NKD" => "Asia/Tokyo"
=> "America/New_York"
f_ownSess(string r) =>
switch r
"6A" => "0820-1500"
"6B" => "0820-1500"
"6C" => "0820-1500"
"6E" => "0820-1500"
"6J" => "0820-1500"
"6M" => "0820-1500"
"6N" => "0820-1500"
"6S" => "0820-1500"
"CL" => "0900-1430"
"GC" => "0820-1330"
"HG" => "0810-1300"
"NG" => "0900-1430"
"NKD" => "0900-1515"
"PA" => "0830-1300"
"PL" => "0820-1305"
"SI" => "0820-1330"
"ZB" => "0820-1500"
"ZC" => "0930-1420"
"ZF" => "0820-1500"
"ZN" => "0820-1500"
"ZS" => "0930-1420"
"ZT" => "0820-1500"
"ZW" => "0930-1420"
=> "0930-1600"
f_ownTz(string r) =>
switch r
"NKD" => "Asia/Tokyo"
=> "America/New_York"
f_ivSym(string r) =>
switch r
"ES" => "CBOE:VIX"
"NQ" => "CBOE:VXN"
"RTY" => "CBOE:RVX"
"GC" => "CBOE:GVZ"
"CL" => "CBOE:OVX"
=> ""
f_kl(string r) =>
switch r
"6A" => "KL1|6A|2026-10-16|4100|4100|atr|390|59.4,29.6,13.5,6.8,1.7|59.3,30.8,15.6,6.9,2|57.5,45.3,32.5,22.3,8.9|56.4,44.1,32.5,23.1,10.6|30,60,90,120,150,210,270,330,360|637,1354,1721,1901,2004,2153,2251,2385,2412,2437,69,321,545,707,797,905,1005,1154,1189,1214,7,79,145,209,262,340,402,502,527,554,3,27,51,83,106,147,180,254,267,280,0,4,8,10,17,29,37,60,67,71|679,1378,1760,1941,2075,2187,2274,2374,2401,2430,87,344,585,724,805,949,1057,1201,1233,1261,16,89,181,250,311,395,464,580,616,638,2,21,43,79,107,148,180,251,267,282,0,1,7,13,19,28,37,62,73,84"
"6B" => "KL1|6B|2026-10-16|4100|4100|atr|390|61.1,32.6,15.7,7.5,2|60,30.8,14.5,6.5,1.9|56.6,44.4,32.1,22.1,9.2|57,44.8,32.8,22.5,10|30,60,90,120,150,210,270,330,360|722,1429,1835,2033,2152,2284,2372,2453,2479,2505,90,370,652,818,941,1049,1154,1288,1308,1335,20,95,213,305,369,448,519,610,625,643,7,31,71,108,142,184,225,286,299,309,0,5,12,20,27,39,51,71,76,80|699,1406,1848,2019,2136,2269,2339,2436,2449,2459,81,357,610,745,852,1001,1093,1213,1240,1263,17,92,203,290,337,427,482,557,577,594,3,23,59,101,124,169,198,250,259,265,0,2,6,15,17,38,51,69,75,78"
"6C" => "KL1|6C|2026-10-16|4100|4100|atr|390|62.4,35.3,19.2,9.8,2.5|62.7,36.1,19.3,9.8,2.5|58.5,43.2,30.1,20.4,8.4|61.3,46.9,33,22,9.4|30,60,90,120,150,210,270,330,360|859,1594,1954,2115,2218,2329,2421,2518,2535,2559,121,453,747,898,1009,1158,1259,1392,1422,1447,15,144,277,359,430,553,624,740,764,787,4,59,111,148,185,249,291,354,378,400,0,12,17,29,36,55,71,90,95,103|871,1565,1960,2132,2236,2348,2435,2532,2552,2572,121,489,779,939,1069,1207,1307,1425,1448,1480,19,150,280,383,467,547,630,735,763,793,2,46,89,125,174,246,291,359,379,401,1,14,19,24,30,44,61,85,94,101"
"6E" => "KL1|6E|2026-10-16|4099|4099|atr|390|60.6,32.4,16.2,7.7,2.4|59.8,31.6,15.1,7.6,2|56.9,43.5,31.2,22.3,9.2|59,45.1,33.1,23,9.6|30,60,90,120,150,210,270,330,360|731,1498,1841,2042,2150,2279,2363,2445,2468,2482,107,405,621,779,885,1032,1161,1279,1315,1328,28,120,219,311,364,437,516,620,648,662,8,38,72,112,138,188,228,293,308,315,1,9,18,26,35,43,57,80,90,97|725,1456,1816,2002,2120,2256,2335,2429,2446,2452,114,397,629,779,880,1022,1134,1252,1279,1295,19,101,215,286,338,428,493,583,598,620,8,40,76,111,139,194,228,291,306,312,1,5,14,20,24,39,49,73,81,84"
"6J" => "KL1|6J|2026-10-16|4099|4099|atr|390|55.9,30.5,15.9,8.2,2.3|56.7,28.6,13,5.7,1.4|54,41.1,29.8,21.6,10.7|56.1,43.3,31.5,22.6,9.9|30,60,90,120,150,210,270,330,360|704,1345,1679,1837,1938,2052,2151,2247,2274,2293,124,416,622,760,845,964,1079,1200,1231,1251,29,144,227,308,370,467,525,614,639,653,6,55,92,130,161,212,249,304,317,335,2,9,17,29,37,48,60,83,87,93|640,1252,1587,1770,1886,2031,2128,2263,2298,2325,112,342,521,644,732,868,983,1104,1144,1174,19,91,164,214,263,322,386,495,514,531,8,27,52,71,95,123,154,208,226,233,1,4,11,13,19,26,36,50,56,58"
"6M" => "KL1|6M|2026-10-16|4098|4098|atr|390|61.4,34.5,18.5,9.2,2.7|63.6,38.9,22.3,12.8,4.2|63,48,32.5,20.8,7.4|57.4,43.9,30.9,21.5,10.1|30,60,90,120,150,210,270,330,360|777,1397,1725,1916,2046,2214,2335,2466,2489,2517,105,359,584,749,873,1048,1185,1345,1385,1413,19,91,173,262,318,454,553,690,727,758,6,22,51,80,119,183,239,323,351,378,1,4,10,14,21,38,50,87,97,109|925,1560,1912,2069,2182,2317,2440,2547,2586,2607,146,493,765,927,1052,1208,1355,1515,1552,1595,33,157,302,397,473,607,710,842,878,912,7,48,104,171,226,320,385,478,504,526,0,8,14,22,40,73,99,141,155,174"
"6N" => "KL1|6N|2026-10-16|4097|4097|atr|390|59.7,29.4,14.1,6.4,1.9|57.8,30.2,13.4,6.2,1.9|56.7,44.2,32.9,23.1,9.4|56.3,43.9,32.4,22.7,10.2|30,60,90,120,150,210,270,330,360|616,1309,1682,1872,1994,2137,2243,2385,2420,2445,77,317,538,668,772,888,993,1136,1174,1203,11,79,146,218,263,336,405,521,554,576,2,26,51,71,93,133,155,225,250,262,0,3,8,14,20,30,40,59,69,77|631,1301,1695,1867,1982,2124,2215,2321,2349,2367,78,319,523,653,754,898,1005,1171,1216,1238,11,70,157,215,259,323,381,484,530,549,2,22,42,68,86,123,152,218,244,255,0,1,5,7,16,25,34,59,69,76"
"6S" => "KL1|6S|2026-10-16|4100|4100|atr|390|61.2,34.5,17.2,8.8,2.9|59.4,30.6,14.6,7.4,1.6|55.5,42.9,31.5,22.5,10|58.9,45.4,32.2,21.7,9|30,60,90,120,150,210,270,330,360|831,1521,1891,2063,2175,2296,2374,2469,2487,2508,146,493,777,936,1030,1159,1276,1371,1395,1413,36,152,285,368,433,522,587,675,695,707,11,57,109,140,167,226,272,332,349,360,2,8,20,37,47,63,79,106,116,120|711,1387,1781,1953,2066,2203,2289,2400,2419,2437,103,388,648,779,875,993,1092,1207,1237,1254,23,107,205,285,339,413,474,565,583,597,7,34,65,94,123,171,209,276,294,303,1,7,15,18,19,26,34,55,58,64"
"BTC" => "KL1|BTC|2026-10-16|2156|2156|atr|390|54.2,27.8,15.6,8.4,3.1|57.3,31.6,16.6,9.9,3.7|56.5,42.3,30.5,22,10.9|54.2,41.3,29.1,20.4,9.3|30,60,90,120,150,210,270,330,360|313,547,699,811,879,985,1055,1117,1141,1168,76,160,221,296,350,444,504,557,578,600,24,70,100,133,162,219,264,303,324,337,13,25,43,58,77,106,139,159,168,181,1,5,9,13,18,32,44,52,61,67|357,622,762,878,945,1062,1130,1192,1215,1236,55,147,258,347,404,481,549,627,661,681,10,52,99,130,175,228,276,318,343,358,7,21,41,63,80,119,155,189,200,214,2,4,9,14,19,36,48,58,69,79"
"CL" => "KL1|CL|2026-10-16|2789|2789|implied|390|71.7,48,29.2,17.2,5.3|72.2,48.9,31.1,19.8,7.7|66.8,55.2,41.9,30.2,14.1|63.5,51.2,39.5,29.3,15.9|30,60,90,120,150,210,270,330,360|845,1286,1580,1717,1800,1880,1933,1985,1995,2001,189,437,711,912,1020,1141,1231,1315,1326,1338,37,143,284,423,498,612,705,784,799,814,10,54,120,195,253,322,388,454,467,480,4,8,25,36,51,74,104,131,140,148|929,1348,1623,1761,1829,1905,1956,2006,2011,2015,228,520,815,985,1082,1192,1259,1339,1355,1364,42,173,346,484,574,698,767,846,860,868,9,54,166,241,324,403,472,540,545,552,1,15,35,63,95,132,166,204,211,214"
"ES" => "KL1|ES|2026-10-16|4137|4137|implied|390|69.2,43.8,25.6,13.5,3.3|67.4,45.3,28.3,18.3,7.2|68.8,50.7,35.6,23.4,9.2|63.1,46.6,33,24.1,11.9|30,60,90,120,150,210,270,330,360|1395,1905,2155,2297,2412,2524,2618,2755,2802,2861,277,631,869,1038,1172,1328,1468,1650,1707,1810,51,176,281,401,487,635,753,885,959,1059,11,50,94,134,179,262,329,436,493,557,3,8,11,18,28,42,64,93,113,138|1460,1944,2187,2311,2399,2512,2598,2691,2734,2787,351,795,1058,1219,1324,1463,1591,1731,1803,1876,76,287,459,575,682,810,932,1052,1104,1169,22,102,191,271,341,447,540,645,702,758,2,7,18,44,70,124,176,218,255,298"
"ETH" => "KL1|ETH|2026-10-16|1385|1385|atr|390|53.6,28.2,14.5,8.2,2.9|61.2,35.2,18.7,10.5,3|57.1,42.3,31.1,21.7,10.5|56,41.7,30.3,20.5,9.9|30,60,90,120,150,210,270,330,360|205,366,459,513,558,619,659,713,727,743,32,92,140,177,214,283,320,359,378,390,11,26,44,61,84,120,142,176,193,201,4,10,20,31,41,62,77,91,102,113,1,8,8,12,14,21,26,32,38,40|247,449,561,623,672,731,789,820,837,847,43,105,179,233,282,343,400,456,474,487,10,35,67,88,106,156,194,234,249,259,5,10,28,37,45,77,105,123,135,146,1,1,4,9,11,16,24,33,37,41"
"GC" => "KL1|GC|2026-10-16|4097|4097|implied|390|65.2,39.5,21.9,12.3,3.8|66.4,41.5,23.6,14.1,5.1|62.7,49.8,38.3,27.4,14|58.4,45.6,34.8,25.6,13.9|30,60,90,120,150,210,270,330,360|1277,1868,2091,2276,2357,2472,2566,2638,2653,2673,277,693,918,1095,1206,1332,1454,1566,1594,1617,68,242,378,468,542,644,733,839,875,899,16,109,169,230,272,338,396,462,490,503,2,18,36,54,67,88,115,140,150,157|1341,1943,2188,2321,2410,2515,2608,2682,2699,2719,363,796,1032,1194,1276,1429,1532,1637,1674,1702,118,318,463,557,618,728,804,912,946,967,40,126,214,277,326,400,454,529,558,577,8,32,57,76,93,129,154,187,201,210"
"HG" => "KL1|HG|2026-10-16|4080|4080|atr|390|59.6,29.6,14.1,6.8,1.6|58.5,30.3,14.7,6.9,1.9|56.5,43.2,32.1,22.2,10.1|56.4,43,31.4,22,10|30,60,90,120,150,210,270,330,360|814,1466,1778,1979,2128,2272,2320,2400,2420,2432,119,367,582,752,882,1040,1091,1177,1192,1208,23,110,203,278,349,447,484,539,559,575,9,39,77,112,153,206,226,254,268,277,1,11,14,18,29,45,53,56,62,66|872,1456,1769,1982,2107,2253,2298,2358,2372,2386,160,389,599,767,892,1038,1094,1176,1204,1235,36,110,205,293,362,458,504,563,584,601,11,40,77,112,144,201,221,257,270,283,1,8,17,26,36,51,58,70,72,78"
"NG" => "KL1|NG|2026-10-16|2773|2773|atr|390|60.9,34.2,18.6,10.6,3|65.3,37.3,19.6,9.4,1.9|60,44.9,32.3,22.3,9.1|61.8,47,33.4,21.5,8|30,60,90,120,150,210,270,330,360|539,867,1178,1299,1405,1521,1612,1672,1682,1689,88,209,429,525,612,749,848,926,941,949,16,51,164,216,257,342,422,493,506,517,6,19,73,97,124,176,224,281,291,293,1,3,14,20,28,44,59,75,79,82|577,929,1262,1377,1475,1615,1709,1793,1802,1812,74,212,440,563,658,806,918,1016,1026,1034,17,47,143,194,251,345,445,523,533,544,4,12,52,75,95,133,193,246,257,261,1,1,6,10,15,21,28,50,51,53"
"NKD" => "KL1|NKD|2026-10-16|4122|4122|atr|375|59.1,33,17.3,8.6,2.3|60.7,34.1,19,10.4,3.3|61,46.8,33.5,22.6,9.6|55.4,42,30,20.8,10.2|30,60,90,120,150,210,270,330,360|1151,1508,1760,1926,2012,2112,2255,2342,2396,2435,250,443,639,796,891,998,1163,1278,1318,1362,60,134,210,289,342,419,549,629,680,713,17,40,82,114,138,169,237,292,334,355,2,2,6,14,22,31,49,76,87,96|1179,1562,1799,1990,2083,2175,2333,2424,2471,2502,256,486,678,816,927,1028,1198,1316,1372,1406,65,151,251,339,399,479,616,708,758,784,12,47,87,129,164,214,306,367,405,430,0,6,12,26,37,49,85,108,121,138"
"NQ" => "KL1|NQ|2026-10-16|4137|4137|implied|390|72.5,49.3,30.5,18.2,4.9|70.8,48.1,32.8,21.9,10.2|71.8,55,39.3,27.2,11.7|64.2,49.2,35.5,26.5,14|30,60,90,120,150,210,270,330,360|1807,2255,2469,2579,2669,2762,2836,2924,2951,2999,605,1017,1236,1404,1514,1668,1779,1898,1950,2038,136,353,523,655,746,893,1005,1132,1195,1261,34,123,212,280,332,440,523,636,688,753,4,15,26,40,51,84,111,148,176,204|1904,2289,2463,2575,2641,2721,2794,2872,2903,2927,663,1125,1351,1487,1569,1696,1788,1898,1945,1990,202,492,682,821,923,1050,1153,1244,1303,1357,60,204,354,447,527,641,717,823,863,905,7,40,85,125,165,236,296,349,383,420"
"PA" => "KL1|PA|2026-10-16|4098|4098|atr|390|60.6,33.2,16.4,7.8,1.7|61.9,34.8,18.9,10.1,3.1|59.5,46.3,33,22.2,9.6|55.2,42.8,30.8,21.8,9.7|30,60,90,120,150,210,270,330,360|913,1508,1823,2034,2164,2381,2431,2458,2471,2483,193,460,700,872,981,1221,1289,1330,1343,1362,50,143,252,344,408,579,623,645,659,674,12,45,99,142,172,262,293,309,316,321,0,4,15,27,33,52,63,68,69,70|1016,1562,1870,2089,2219,2397,2456,2502,2521,2536,224,537,757,956,1068,1288,1348,1397,1410,1425,70,191,310,426,520,666,717,749,766,775,31,85,145,197,258,347,372,388,400,412,5,21,39,55,67,110,115,120,123,126"
"PL" => "KL1|PL|2026-10-16|4098|4098|atr|390|60.9,33.1,15.5,7.1,1.6|61.6,33.9,17.3,8.2,2.1|58.2,44.8,32.1,21.2,9.2|56.8,44.7,32.4,23,10|30,60,90,120,150,210,270,330,360|1011,1622,1911,2107,2218,2352,2421,2466,2487,2496,145,460,683,879,1002,1155,1271,1317,1330,1355,29,112,205,318,380,488,564,615,628,637,9,30,63,101,138,197,244,269,282,290,0,3,7,16,25,43,51,58,60,64|1048,1633,1933,2134,2229,2372,2445,2500,2519,2526,197,510,733,919,1027,1207,1283,1350,1374,1390,51,165,263,354,441,560,620,679,700,709,21,57,100,150,190,250,288,315,330,337,2,11,15,26,38,57,66,73,79,87"
"RTY" => "KL1|RTY|2026-10-16|2353|2353|implied|390|72.6,51.5,34,21.1,6.9|75.1,55.1,38.7,25.6,11.1|71.2,56.6,42.6,29.9,14.2|67.9,54.1,42,30.6,15.5|30,60,90,120,150,210,270,330,360|1175,1369,1445,1505,1548,1605,1643,1680,1692,1708,459,709,843,913,960,1038,1095,1155,1180,1212,155,315,415,498,551,617,661,737,766,800,49,125,191,236,280,349,397,446,468,497,6,17,31,46,66,84,104,131,145,162|1255,1474,1568,1617,1637,1678,1716,1748,1758,1767,519,810,942,1029,1081,1155,1205,1251,1275,1297,163,381,514,595,659,736,797,864,886,910,44,156,239,306,362,433,494,550,569,603,5,22,43,69,92,129,169,211,236,261"
"SI" => "KL1|SI|2026-10-16|4080|4080|atr|390|59.2,32,17.7,8.9,2.8|62,34.2,19.2,10.4,3.6|59.7,44.2,31.1,21.4,9.9|56.3,41.6,29.7,21,10.1|30,60,90,120,150,210,270,330,360|1069,1613,1847,2019,2115,2212,2284,2360,2389,2415,201,500,703,848,941,1061,1169,1258,1288,1304,49,179,279,369,438,522,597,677,698,724,13,63,116,163,188,240,285,331,348,363,1,10,22,30,44,63,75,99,106,114|1124,1666,1938,2105,2193,2306,2404,2485,2508,2529,289,614,812,949,1033,1157,1242,1351,1373,1396,85,243,343,432,501,592,665,729,763,784,31,98,151,195,244,293,339,389,413,426,10,23,48,60,74,102,117,133,142,147"
"YM" => "KL1|YM|2026-10-16|4124|4124|atr|390|66.1,38.7,21.4,10.9,2.8|65.2,40.8,23.8,14.6,5.2|66.1,46.4,31.6,19.7,7.3|60.9,43.8,29.6,20.7,9.3|30,60,90,120,150,210,270,330,360|1393,1831,2038,2172,2280,2421,2511,2625,2665,2728,340,628,803,961,1050,1190,1306,1434,1509,1596,74,185,280,373,444,543,643,742,810,883,21,52,94,131,169,230,278,354,394,449,5,13,23,27,35,46,57,79,88,115|1405,1836,2060,2198,2276,2419,2510,2615,2641,2688,361,692,913,1062,1163,1294,1418,1552,1609,1681,88,234,362,464,559,659,761,887,934,982,18,94,154,213,265,344,413,512,551,603,2,9,20,36,50,86,121,166,187,215"
"ZB" => "KL1|ZB|2026-10-16|4117|4117|atr|390|63.5,37.1,19.7,9.6,2.2|60.2,34.4,18.3,9.5,2.4|60.2,46.1,33.1,22.3,8.5|58.7,46,33,22.2,8.7|30,60,90,120,150,210,270,330,360|927,1590,1883,2078,2204,2344,2476,2574,2591,2613,119,439,629,826,947,1142,1334,1465,1500,1529,12,118,202,295,356,474,621,742,775,813,3,31,71,115,150,206,272,342,370,394,1,2,10,17,24,31,45,68,81,92|893,1498,1768,1949,2041,2183,2323,2425,2453,2478,132,408,606,786,900,1049,1217,1347,1384,1416,32,128,197,275,350,447,581,690,719,752,7,43,67,107,142,199,278,349,372,390,1,7,13,20,24,36,55,82,91,98"
"ZC" => "KL1|ZC|2026-10-16|3278|3278|atr|390|65.9,40.2,23.8,13,4|68.2,41.9,23.7,12.2,3.4|63.7,46.5,30.9,19.2,7.2|66.7,48.4,31.7,18.6,6.4|30,60,90,120,150,210,270,330,360|1358,1612,1774,1852,1929,2046,2116,2160,2160,2160,431,627,802,903,982,1184,1264,1318,1318,1318,109,220,333,406,464,635,726,780,780,780,25,70,119,158,207,340,398,427,427,427,2,9,17,29,42,96,125,132,132,132|1417,1689,1854,1967,2038,2158,2210,2237,2237,2237,415,664,841,963,1063,1251,1326,1375,1375,1375,99,217,326,406,466,650,733,776,776,776,19,64,122,152,194,316,367,401,401,401,6,9,17,25,39,89,105,113,113,113"
"ZF" => "KL1|ZF|2026-10-16|4126|4126|atr|390|63.2,35.7,19.3,10.1,2.9|58.6,32.8,17.7,9.6,3|59,45.3,31.8,21.3,9|58.5,45.1,32.8,21.7,8.7|30,60,90,120,150,210,270,330,360|897,1553,1842,2018,2150,2318,2468,2563,2589,2609,130,469,643,817,933,1097,1270,1426,1451,1474,30,151,242,326,406,501,613,730,769,797,2,53,83,127,169,210,279,369,396,418,1,6,15,22,32,44,58,95,105,118|783,1386,1664,1874,1981,2107,2245,2367,2401,2419,131,410,570,711,822,958,1130,1298,1325,1354,30,141,203,263,332,420,527,669,704,729,10,57,92,123,157,211,273,366,386,396,0,9,15,18,27,37,61,104,117,122"
"ZN" => "KL1|ZN|2026-10-16|4111|4111|atr|390|63.5,36.7,19.3,9.7,2.4|59.1,33.2,17.3,9.3,2.4|59.1,46.1,32.9,22.2,9.1|58.4,46,33.2,21.7,8.4|30,60,90,120,150,210,270,330,360|934,1619,1875,2062,2193,2354,2480,2574,2596,2611,117,471,648,837,950,1114,1302,1453,1489,1507,21,134,225,306,391,496,623,743,769,793,2,39,76,114,158,196,271,347,378,400,1,4,13,20,26,38,58,84,92,100|850,1472,1729,1914,2011,2131,2265,2376,2408,2430,128,396,568,734,844,977,1152,1300,1336,1364,29,139,202,263,328,418,530,658,684,713,11,51,74,104,134,183,252,340,367,383,0,6,14,16,21,38,55,83,91,99"
"ZS" => "KL1|ZS|2026-10-16|3290|3290|atr|390|65.2,38.4,22.1,12.4,3.5|68.8,41.6,23.1,11.7,3.3|66.6,48.3,32.1,20.8,7.8|63.1,46,28.9,17.8,6.4|30,60,90,120,150,210,270,330,360|1338,1598,1750,1844,1925,2057,2122,2145,2145,2145,375,574,766,880,969,1145,1230,1263,1263,1263,92,203,310,374,453,610,678,727,727,727,33,66,114,150,201,316,372,407,407,407,3,9,18,24,30,83,107,115,115,115|1421,1700,1866,1962,2039,2187,2240,2265,2265,2265,402,612,799,915,1016,1236,1326,1369,1369,1369,79,193,304,385,461,635,720,759,759,759,17,51,97,137,175,297,358,385,385,385,1,4,12,19,33,77,101,109,109,109"
"ZT" => "KL1|ZT|2026-10-16|4130|4130|atr|390|63.2,35.7,19.6,10.3,3.7|60.8,33.8,17.1,9.7,3.3|58.2,43.7,30.8,21,8.8|59.5,45.2,32.1,21.4,8.6|30,60,90,120,150,210,270,330,360|1092,1683,1930,2112,2224,2353,2465,2570,2590,2611,185,505,686,833,932,1088,1250,1405,1442,1475,43,176,254,338,401,512,608,740,781,809,12,68,102,145,181,233,297,381,403,426,0,7,20,32,43,56,77,126,142,152|940,1475,1727,1912,2036,2193,2322,2439,2477,2512,167,452,595,730,822,973,1135,1311,1359,1398,39,146,211,276,332,428,512,652,679,707,13,50,79,110,148,206,259,368,389,400,1,15,18,24,31,46,68,118,129,137"
"ZW" => "KL1|ZW|2026-10-16|3289|3289|atr|390|64.8,39.9,23,13.1,3.9|69.9,43.5,23.8,11.8,2.5|64.2,46.4,30.7,19.6,8.1|67.1,49.2,32.4,19.4,5.4|30,60,90,120,150,210,270,330,360|1378,1647,1792,1879,1941,2056,2095,2132,2132,2132,413,653,844,965,1048,1201,1270,1312,1312,1312,123,236,356,432,509,637,703,756,756,756,24,69,128,184,234,348,392,431,431,431,0,4,15,29,40,100,118,129,129,129|1460,1737,1923,2013,2082,2195,2244,2298,2298,2298,433,705,923,1040,1129,1289,1373,1430,1430,1430,100,237,353,439,512,671,749,784,784,784,18,68,131,177,219,315,352,388,388,388,1,2,9,13,24,62,72,81,81,81"
=> ""
// --- END GENERATED CONSTANTS
// --- BEGIN SHARED CORE
// One session state machine, fed bar by bar. The same code runs (a) inside a fixed-timeframe request, where the chart
// keeps enough sessions for the 20-session average range and the row size, and (b) on the chart bars (or on their
// intrabars when the chart timeframe does not line up with the session), for what happens inside today's session.
type Sess
int startMin = 570
int endMin = 960
string tz = "America/New_York"
int ibMin = 60
int orMin = 15
int rowTicks = 0
bool active = false
int count = 0
int finished = 0
int dayKey = 0
int startTime = 0
int elapsed = 0
int lastDow = 0
int lastMonth = 0
float o = na
float h = na
float l = na
float c = na
float orH = na
float orL = na
bool orDone = false
float ibH = na
float ibL = na
bool ibDone = false
bool brkOrUp = false
bool brkOrDn = false
bool brkIbUp = false
bool brkIbDn = false
bool gapFilled = false
float step = na
float nextStep = na
array<float> perH
array<float> perL
float pO = na
float pH = na
float pL = na
float pC = na
float pVAH = na
float pVAL = na
float pPOC = na
float pStep = na
int pDayKey = 0
int pDow = 0
int pStart = 0
array<float> pPerH
array<float> pPerL
array<float> ranges
array<float> trs
float atr = na
float wO = na
float wH = na
float wL = na
float pwH = na
float pwL = na
bool wPartial = true
float mO = na
float mH = na
float mL = na
float pmH = na
float pmL = na
bool mPartial = true
f_newSess(int startMin, int endMin, string tz, int ibMin, int orMin, int rowTicks) =>
Sess.new(startMin = startMin, endMin = endMin, tz = tz, ibMin = ibMin, orMin = orMin, rowTicks = rowTicks, perH = array.new<float>(), perL = array.new<float>(), pPerH = array.new<float>(), pPerL = array.new<float>(), ranges = array.new<float>(), trs = array.new<float>())
// "HHMM-HHMM" -> minutes of the day
f_sessStart(string s) =>
int(str.tonumber(str.substring(s, 0, 2)) * 60 + str.tonumber(str.substring(s, 2, 4)))
f_sessEnd(string s) =>
int(str.tonumber(str.substring(s, 5, 7)) * 60 + str.tonumber(str.substring(s, 7, 9)))
// Row size of the profile: a round number of ticks that gives about 45 rows for a typical session
// (the median range of up to 60 sessions before the one being read). rowTicks > 0 overrides it.
f_autoStep(array<float> ranges, int rowTicks, float fallbackRange) =>
float typical = fallbackRange
int n = ranges.size()
if n > 0
array<float> srt = ranges.copy()
srt.sort(order.ascending)
typical := srt.get(int(math.floor(n / 2)))
int k = int(math.max(1, math.ceil(nz(typical, syminfo.mintick * 45) / 45 / syminfo.mintick)))
int ticks = k
array<int> nice = array.from(1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 200, 250, 500, 1000)
bool found = false
for v in nice
if not found and v >= k
ticks := v
found := true
if rowTicks > 0
ticks := rowTicks
ticks * syminfo.mintick
f_row(float price, float step) =>
int(math.floor(price / step + 1e-9))
// Point of control and 70% value area from the highs and lows of the 30-minute periods of one session.
// POC = the row with the most periods; ties go to the row closest to the middle of the range, then the higher one.
// Value area = grown from the POC one row at a time toward the side with more periods (ties up) until 70%.
// A row is named by its lower price, like the profile page of the portal.
f_profile(array<float> perH, array<float> perL, float step) =>
float poc = na
float vah = na
float val = na
int bot = na
int top = na
int np = perH.size()
if np > 0 and not na(step) and step > 0
for i = 0 to np - 1
float ph = perH.get(i)
float pl = perL.get(i)
if not na(ph) and not na(pl)
int rl = f_row(pl, step)
int rh = f_row(ph, step)
bot := na(bot) ? rl : math.min(bot, rl)
top := na(top) ? rh : math.max(top, rh)
if not na(bot) and top - bot < 5000
int nrows = top - bot + 1
array<int> counts = array.new<int>(nrows, 0)
for i = 0 to np - 1
float ph = perH.get(i)
float pl = perL.get(i)
if not na(ph) and not na(pl)
int rl = f_row(pl, step) - bot
int rh = f_row(ph, step) - bot
for r = rl to rh
counts.set(r, counts.get(r) + 1)
int mx = counts.max()
float mid = (nrows - 1) / 2.0
int pr = -1
float best = na
for r = 0 to nrows - 1
if counts.get(r) == mx
float d = math.abs(r - mid)
if pr < 0 or d <= best
pr := r
best := d
int total = counts.sum()
int loR = pr
int hiR = pr
float acc = counts.get(pr)
while acc < 0.70 * total and (loR > 0 or hiR < nrows - 1)
int up = hiR < nrows - 1 ? counts.get(hiR + 1) : -1
int dn = loR > 0 ? counts.get(loR - 1) : -1
if up >= dn
hiR += 1
acc += up
else
loR -= 1
acc += dn
poc := math.round_to_mintick((bot + pr) * step)
vah := math.round_to_mintick((bot + hiR) * step)
val := math.round_to_mintick((bot + loR) * step)
[poc, vah, val]
// Closes the running session: its levels become the "prior session" ones.
method finish(Sess s) =>
if s.active
s.active := false
s.finished := s.finished + 1
float rng = s.h - s.l
[poc, vah, val] = f_profile(s.perH, s.perL, s.step)
float tr = na(s.pC) ? rng : math.max(rng, math.max(math.abs(s.h - s.pC), math.abs(s.l - s.pC)))
s.trs.push(tr)
if s.trs.size() > 20
s.trs.shift()
s.ranges.push(rng)
if s.ranges.size() > 60
s.ranges.shift()
s.atr := s.trs.size() >= 5 ? s.trs.avg() : na
s.nextStep := f_autoStep(s.ranges, s.rowTicks, rng)
s.pO := s.o
s.pH := s.h
s.pL := s.l
s.pC := s.c
s.pPOC := poc
s.pVAH := vah
s.pVAL := val
s.pStep := s.step
s.pDayKey := s.dayKey
s.pDow := s.lastDow
s.pStart := s.startTime
s.pPerH := s.perH.copy()
s.pPerL := s.perL.copy()
s.wH := na(s.wH) ? s.h : math.max(s.wH, s.h)
s.wL := na(s.wL) ? s.l : math.min(s.wL, s.l)
s.mH := na(s.mH) ? s.h : math.max(s.mH, s.h)
s.mL := na(s.mL) ? s.l : math.min(s.mL, s.l)
s.finished
// Opens a new session at the bar that starts at time t (off = minutes after the nominal session open).
method begin(Sess s, int t, int off, int key, int dow, float o) =>
bool first = s.lastDow == 0
bool newWeek = first or dow <= s.lastDow or t - s.startTime > 6 * 86400000
if newWeek
s.pwH := s.wPartial ? na : s.wH
s.pwL := s.wPartial ? na : s.wL
s.wPartial := first and dow != dayofweek.monday
s.wH := na
s.wL := na
s.wO := o
int mon = month(t, s.tz)
if mon != s.lastMonth
s.pmH := s.mPartial ? na : s.mH
s.pmL := s.mPartial ? na : s.mL
s.mPartial := first
s.mH := na
s.mL := na
s.mO := o
s.lastDow := dow
s.lastMonth := mon
s.dayKey := key
s.startTime := t - off * 60000
s.active := true
s.count := s.count + 1
s.o := o
s.h := na
s.l := na
s.c := na
s.orH := na
s.orL := na
s.orDone := false
s.ibH := na
s.ibL := na
s.ibDone := false
s.brkOrUp := false
s.brkOrDn := false
s.brkIbUp := false
s.brkIbDn := false
s.gapFilled := false
s.elapsed := 0
s.step := f_autoStep(s.ranges, s.rowTicks, na)
s.perH := array.new<float>()
s.perL := array.new<float>()
s.count
// One bar (or intrabar) that starts at time t and lasts dur minutes; done = the bar is complete.
method feed(Sess s, int t, int dur, bool done, float o, float h, float l, float c) =>
int mins = hour(t, s.tz) * 60 + minute(t, s.tz)
int dow = dayofweek(t, s.tz)
bool inWin = mins >= s.startMin and mins < s.endMin and dow != dayofweek.saturday and dow != dayofweek.sunday and not na(h) and not na(l)
int key = year(t, s.tz) * 10000 + month(t, s.tz) * 100 + dayofmonth(t, s.tz)
if s.active and (not inWin or key != s.dayKey)
s.finish()
if inWin
int off = mins - s.startMin
if key != s.dayKey
s.begin(t, off, key, dow, o)
s.h := na(s.h) ? h : math.max(s.h, h)
s.l := na(s.l) ? l : math.min(s.l, l)
s.c := c
s.elapsed := off + dur
// opening range: bars that start inside the window build it; the first bar after it fixes it
if off < s.orMin
s.orH := na(s.orH) ? h : math.max(s.orH, h)
s.orL := na(s.orL) ? l : math.min(s.orL, l)
else
s.orDone := true
if h > s.orH
s.brkOrUp := true
if l < s.orL
s.brkOrDn := true
if off < s.ibMin
s.ibH := na(s.ibH) ? h : math.max(s.ibH, h)
s.ibL := na(s.ibL) ? l : math.min(s.ibL, l)
else
s.ibDone := true
if h > s.ibH
s.brkIbUp := true
if l < s.ibL
s.brkIbDn := true
// gap against the previous session's last price: filled when price trades back at it
if not na(s.pC) and not s.gapFilled
if (s.o > s.pC and l <= s.pC) or (s.o < s.pC and h >= s.pC)
s.gapFilled := true
// highs and lows of the 30-minute periods (A = first 30 minutes)
int k = int(math.floor(off / 30))
while s.perH.size() <= k
s.perH.push(na)
s.perL.push(na)
float ph = s.perH.get(k)
float pl = s.perL.get(k)
s.perH.set(k, na(ph) ? h : math.max(ph, h))
s.perL.set(k, na(pl) ? l : math.min(pl, l))
// the bar that ends the window closes the session (once that bar is complete)
if done and s.elapsed >= s.endMin - s.startMin
s.finish()
s.count
// The deep-history context: prior-session levels, 20-session average true range of the regular session, row size,
// week and month references. Evaluated on a fixed timeframe so that a 1-minute chart has the same history as a
// 60-minute one. Everything it returns is final when the session it describes has ended.
f_ctx(int startMin, int endMin, string tz, int rowTicks, int dur) =>
var Sess s = f_newSess(startMin, endMin, tz, 60, 15, rowTicks)
s.feed(time, dur, barstate.isconfirmed, open, high, low, close)
[s.finished, s.pDayKey, s.pDow, s.lastMonth, s.pStart, s.pO, s.pH, s.pL, s.pC, s.pVAH, s.pVAL, s.pPOC, s.atr, s.trs.size(), s.pStep, s.nextStep, s.wO, s.wH, s.wL, s.pwH, s.pwL, s.wPartial, s.mO, s.mH, s.mL, s.pmH, s.pmL, s.mPartial]
// Timeframe of the deep-history context and of the intrabars: the coarsest of 15 / 5 / 1 minutes the session lines up with.
f_gridTf(int a, int b, int cap) =>
a % 15 == 0 and b % 15 == 0 and cap >= 15 ? 15 : a % 5 == 0 and b % 5 == 0 and cap >= 5 ? 5 : 1
// --- END SHARED CORE
// ------------------------------------------------------------------------------------------------------------ inputs
string G0 = "General"
string lang = input.string("es", "Idioma / Language / Idioma", options = ["es", "en", "pt"], group = G0)
string marketIn = input.string("Auto", "Mercado de las estadísticas / Market", options = ["Auto", "ES", "NQ", "RTY", "YM", "NKD", "GC", "SI", "HG", "PL", "PA", "CL", "NG", "ZN", "ZB", "ZF", "ZT", "ZC", "ZS", "ZW", "6E", "6J", "6B", "6A", "6C", "6S", "6N", "6M", "BTC", "ETH"], group = G0, tooltip = "Auto: se toma del símbolo del gráfico (los micros usan las estadísticas de su contrato grande). / Auto: taken from the chart symbol.")
string pasteIn = input.string("", "Estadísticas actualizadas (pegar línea KL1, opcional) / Updated statistics", group = G0, tooltip = "Pega aquí la línea que empieza por KL1 desde la página de indicadores del portal para actualizar las frecuencias sin volver a copiar el script. Vacío = las que vienen en el código.")
string G1 = "Sesión / Session"
bool sessAuto = input.bool(true, "Sesión según el mercado (recomendado)", group = G1, tooltip = "Usa la sesión con la que están medidas las frecuencias. Si la desactivas, los niveles se calculan con la sesión manual y las frecuencias dejan de mostrarse.")
string sessManual = input.session("0930-1600", "Sesión manual (HHMM-HHMM)", group = G1)
string tzManual = input.string("America/New_York", "Zona horaria de la sesión manual", group = G1)
int ibMinIn = input.int(60, "Balance inicial (minutos)", minval = 5, maxval = 240, step = 5, group = G1)
int orMinIn = input.int(15, "Rango de apertura (minutos)", minval = 1, maxval = 120, group = G1)
string srcMode = input.string("Auto", "Datos para la sesión de hoy", options = ["Auto", "Velas del gráfico", "Intrabarras"], group = G1, tooltip = "Auto: usa las velas del gráfico cuando su temporalidad encaja con la apertura de la sesión y con los periodos de 30 minutos; si no encaja (por ejemplo 60 minutos con apertura a las 9:30), usa intrabarras de 5 o de 1 minuto.")
int rowTicksIn = input.int(0, "Tamaño de fila del perfil en ticks (0 = automático)", minval = 0, group = G1, tooltip = "Automático: un número redondo de ticks que da unas 45 filas para una sesión típica (mediana del rango de hasta 60 sesiones anteriores).")
string G2 = "Rango esperado / Expected range"
string emMode = input.string("Auto", "Método", options = ["Auto", "ATR", "Volatilidad implícita"], group = G2, tooltip = "Auto: el mismo método con que se midieron las frecuencias de ese mercado. ATR = 0,88 × rango verdadero medio de 20 sesiones regulares. Volatilidad implícita = 0,8 × cierre × índice / 100 / raíz de 252.")
float ivManual = input.float(0.0, "Índice de volatilidad implícita, valor manual (0 = no usar)", minval = 0.0, step = 0.1, group = G2, tooltip = "Si lo escribes, se usa para las sesiones de los últimos 4 días del gráfico en lugar del valor pedido al símbolo. Es el valor del índice de volatilidad del mercado (por ejemplo 15,4).")
string ivSymIn = input.string("", "Símbolo del índice de volatilidad (vacío = automático)", group = G2)
string G3 = "Niveles / Levels"
bool showPrior = input.bool(true, "Máximo, mínimo y cierre de la sesión anterior", group = G3)
bool showMid = input.bool(false, "Punto medio de la sesión anterior", group = G3)
bool showValue = input.bool(true, "Área de valor y POC de la sesión anterior", group = G3)
bool showWeek = input.bool(true, "Máximo y mínimo de la semana anterior", group = G3)
bool showCurWeek = input.bool(true, "Apertura, máximo y mínimo de la semana en curso (hasta ayer)", group = G3)
bool showMonth = input.bool(true, "Máximo y mínimo del mes anterior y apertura del mes", group = G3)
bool showOR = input.bool(true, "Rango de apertura", group = G3)
bool showIB = input.bool(true, "Balance inicial", group = G3)
bool showObj = input.bool(true, "Banda del rango esperado desde el cierre anterior (±1 ME)", group = G3)
bool showLadder = input.bool(true, "Escalera desde la apertura (0,25 a 1,5 ME)", group = G3)
bool showCloseLadder = input.bool(false, "Escalera completa desde el cierre también durante la sesión", group = G3)
string G4 = "Dibujo / Drawing"
int drawDays = input.int(3, "Días de gráfico con niveles dibujados", minval = 1, maxval = 30, group = G4)
bool keepHist = input.bool(true, "Conservar los niveles de las sesiones anteriores", group = G4)
float mergePct = input.float(3.0, "Unir etiquetas a menos de este % del rango esperado", minval = 0.0, maxval = 25.0, step = 0.5, group = G4)
int labOffset = input.int(12, "Separación de las etiquetas antes de la apertura (velas)", minval = 1, maxval = 200, group = G4)
string sizeIn = input.string("small", "Tamaño del texto", options = ["tiny", "small", "normal"], group = G4)
bool showTable = input.bool(true, "Tabla", group = G4)
string tablePos = input.string("top_right", "Posición de la tabla", options = ["top_right", "top_left", "bottom_right", "bottom_left", "middle_right"], group = G4)
string G5 = "Colores / Colours"
color cPrior = input.color(#8b98a8, "Sesión anterior", group = G5)
color cValue = input.color(#a78bfa, "Área de valor y POC", group = G5)
color cWeek = input.color(#38bdf8, "Semana", group = G5)
color cMonth = input.color(#f472b6, "Mes", group = G5)
color cOR = input.color(#fbbf24, "Rango de apertura", group = G5)
color cIB = input.color(#f59e0b, "Balance inicial", group = G5)
color cUp = input.color(#26a69a, "Rango esperado arriba", group = G5)
color cDn = input.color(#ef5350, "Rango esperado abajo", group = G5)
color cText = input.color(#c9d1d9, "Texto de la tabla", group = G5)
color cTableBg = input.color(color.new(#0d1117, 15), "Fondo de la tabla", group = G5)
// ------------------------------------------------------------------------------------------------------------- setup
f_t(string es, string en, string pt) =>
lang == "es" ? es : lang == "en" ? en : pt
string root = marketIn == "Auto" ? f_parent(syminfo.root) : marketIn
string lvSpec = sessAuto ? f_lvSess(root) : sessManual
string lvTz = sessAuto ? f_lvTz(root) : tzManual
string ownSpec = sessAuto ? f_ownSess(root) : sessManual
string ownTz = sessAuto ? f_ownTz(root) : tzManual
int lvStart = f_sessStart(lvSpec)
int lvEnd = f_sessEnd(lvSpec)
int ownStart = f_sessStart(ownSpec)
int ownEnd = f_sessEnd(ownSpec)
bool okTf = timeframe.isminutes and timeframe.multiplier <= 60
int mult = timeframe.multiplier
bool aligned = lvStart % mult == 0 and lvEnd % mult == 0 and ownStart % mult == 0 and ownEnd % mult == 0 and 30 % mult == 0 and orMinIn % mult == 0 and ibMinIn % mult == 0
bool useLtf = okTf and mult > 1 and (srcMode == "Intrabarras" or (srcMode == "Auto" and not aligned))
int ltfDur = math.min(f_gridTf(lvStart, lvEnd, mult - 1), f_gridTf(ownStart, ownEnd, mult - 1))
ltfDur := orMinIn % ltfDur == 0 and ibMinIn % ltfDur == 0 ? ltfDur : 1
string ltfTf = str.tostring(ltfDur)
int ctxDur = f_gridTf(lvStart, lvEnd, 15)
string ctxTf = str.tostring(ctxDur)
// --------------------------------------------------------------------------------------------------- statistics line
type Stats
bool ok = false
string through = ""
float n = 0
float nClose = 0
string method = "atr"
int total = 390
array<float> openUp
array<float> openDn
array<float> closeUp
array<float> closeDn
array<float> marks
array<float> clockUp
array<float> clockDn
f_nums(string s) =>
array<float> out = array.new<float>()
if s != ""
array<string> parts = str.split(s, ",")
for p in parts
out.push(str.tonumber(p))
out
// KL1|root|data through|n from the open|n from the close|method|session minutes|open up|open down|close up|close down|clock marks|clock up|clock down
f_stats(string src) =>
Stats st = Stats.new(openUp = array.new<float>(), openDn = array.new<float>(), closeUp = array.new<float>(), closeDn = array.new<float>(), marks = array.new<float>(), clockUp = array.new<float>(), clockDn = array.new<float>())
array<string> f = str.split(src, "|")
if f.size() >= 14 and f.get(0) == "KL1"
st.through := f.get(2)
st.n := str.tonumber(f.get(3))
st.nClose := str.tonumber(f.get(4))
st.method := f.get(5)
st.total := int(str.tonumber(f.get(6)))
st.openUp := f_nums(f.get(7))
st.openDn := f_nums(f.get(8))
st.closeUp := f_nums(f.get(9))
st.closeDn := f_nums(f.get(10))
st.marks := f_nums(f.get(11))
st.clockUp := f_nums(f.get(12))
st.clockDn := f_nums(f.get(13))
int w = st.marks.size() + 1
st.ok := st.openUp.size() == 5 and st.openDn.size() == 5 and st.closeUp.size() == 5 and st.closeDn.size() == 5 and st.clockUp.size() == 5 * w and st.clockDn.size() == 5 * w and st.n > 0
st
string pasted = str.trim(pasteIn)
bool pasteOk = str.startswith(pasted, "KL1|" + root + "|")
var Stats stats = f_stats(pasteOk ? pasted : f_kl(root))
// frequencies describe the session they were measured on: a manual session switches them off
bool statsOn = stats.ok and sessAuto
var array<float> RUNGS = array.from(0.25, 0.5, 0.75, 1.0, 1.5)
f_at(array<float> a, int i) =>
float v = na
if i >= 0 and i < a.size()
v := a.get(i)
v
// Share of the sessions that had NOT reached rung ri by the last clock mark already passed and still reached it
// before the close. na before the first mark.
f_left(Stats st, bool up, int ri, int minute) =>
float res = na
int nm = st.marks.size()
int mk = -1
if nm > 0
for j = 0 to nm - 1
if st.marks.get(j) <= minute
mk := j
if mk >= 0
array<float> a = st.clockDn
if up
a := st.clockUp
int w = nm + 1
float byNow = f_at(a, ri * w + mk)
float fin = f_at(a, ri * w + nm)
float left = st.n - byNow
res := left > 0 ? 100.0 * (fin - byNow) / left : na
res
f_markAt(Stats st, int minute) =>
int mk = -1
int nm = st.marks.size()
if nm > 0
for j = 0 to nm - 1
if st.marks.get(j) <= minute
mk := j
mk
f_pct(float v) =>
na(v) ? "—" : str.tostring(v, "0.0") + "%"
f_px(float v) =>
na(v) ? "—" : str.tostring(v, format.mintick)
f_hhmm(int m) =>
str.tostring(math.floor(m / 60), "00") + ":" + str.tostring(m % 60, "00")
f_rung(float r) =>
str.tostring(r, "0.##")
// ------------------------------------------------------------------------------------------------------ data requests
[cFin, cKey, cDow, cMon, cStart, cO, cH, cL, cC, cVAH, cVAL, cPOC, cAtr, cTrN, cStep, cNextStep, cWO, cWH, cWL, cPWH, cPWL, cWPartial, cMO, cMH, cML, cPMH, cPML, cMPartial] = request.security(syminfo.tickerid, ctxTf, f_ctx(lvStart, lvEnd, lvTz, rowTicksIn, ctxDur), lookahead = barmerge.lookahead_off)
// Implied-volatility index of the market, daily. close[1] and close[2] with lookahead are values already published
// when the bar is read (no future data): which of the two is used depends on the day the levels are for.
string ivAuto = f_ivSym(root)
string ivSym = ivSymIn != "" ? ivSymIn : ivAuto
bool hasIv = ivSym != ""
[ivT, ivC1, ivC2] = request.security(hasIv ? ivSym : syminfo.tickerid, "D", [time, close[1], close[2]], lookahead = barmerge.lookahead_on, ignore_invalid_symbol = true)
// The index before the prior session's close: the value our frequencies were measured with.
f_ivFor(int priorKey) =>
float v = na
if hasIv and not na(ivT)
int k = year(ivT, "America/New_York") * 10000 + month(ivT, "America/New_York") * 100 + dayofmonth(ivT, "America/New_York")
v := k <= priorKey ? ivC1 : ivC2
v
// ------------------------------------------------------------------------------------------------------ today's bars
var Sess lv = f_newSess(lvStart, lvEnd, lvTz, 60, 15, rowTicksIn)
var Sess own = f_newSess(ownStart, ownEnd, ownTz, ibMinIn, orMinIn, rowTicksIn)
int lvCount0 = lv.count
int ownCount0 = own.count
bool ownOr0 = own.orDone
bool ownIb0 = own.ibDone
if okTf
if useLtf
[lt, lo, lh, ll, lc] = request.security_lower_tf(syminfo.tickerid, ltfTf, [time, open, high, low, close])
int nl = lt.size()
if nl > 0
for i = 0 to nl - 1
bool done = i < nl - 1 or barstate.isconfirmed
lv.feed(lt.get(i), ltfDur, done, lo.get(i), lh.get(i), ll.get(i), lc.get(i))
own.feed(lt.get(i), ltfDur, done, lo.get(i), lh.get(i), ll.get(i), lc.get(i))
else
lv.feed(time, mult, barstate.isconfirmed, open, high, low, close)
own.feed(time, mult, barstate.isconfirmed, open, high, low, close)
bool evOpen = lv.count != lvCount0
bool evOwnOpen = own.count != ownCount0
bool evOr = own.orDone and not ownOr0
bool evIb = own.ibDone and not ownIb0
bool evFin = not na(cFin) and cFin != nz(cFin[1]) and not lv.active
// ------------------------------------------------------------------------------------------------------------ levels
var int phase = 0 // 1 = session in progress or just ended, 2 = plan for the next session (before the open)
var float kPH = na
var float kPL = na
var float kPC = na
var float kMid = na
var float kVAH = na
var float kVAL = na
var float kPOC = na
var float kPWH = na
var float kPWL = na
var float kWO = na
var float kCWH = na
var float kCWL = na
var float kPMH = na
var float kPML = na
var float kMO = na
var float kOpen = na
var float kEM = na
var string kMethod = ""
var float kIv = na
var float kORH = na
var float kORL = na
var float kIBH = na
var float kIBL = na
var array<float> rungUp = array.new<float>(5, na)
var array<float> rungDn = array.new<float>(5, na)
var array<float> cRungUp = array.new<float>(5, na)
var array<float> cRungDn = array.new<float>(5, na)
int phase0 = phase
if evOpen or evFin
phase := evOpen ? 1 : 2
kPH := cH
kPL := cL
kPC := cC
kMid := na(cH) ? na : math.round_to_mintick((cH + cL) / 2)
kVAH := cVAH
kVAL := cVAL
kPOC := cPOC
// week and month: decided by the day the levels are for (before the open, a Friday close means a new week)
int dowD = evOpen ? dayofweek(lv.startTime, lvTz) : na
bool newWeek = evOpen ? (na(cDow) or dowD <= cDow or lv.startTime - cStart > 6 * 86400000) : cDow == dayofweek.friday
kPWH := newWeek ? (cWPartial ? na : cWH) : cPWH
kPWL := newWeek ? (cWPartial ? na : cWL) : cPWL
kCWH := newWeek ? na : cWH
kCWL := newWeek ? na : cWL
kWO := newWeek ? (evOpen ? lv.o : na) : cWO
bool newMonth = evOpen ? month(lv.startTime, lvTz) != cMon : false
kPMH := newMonth ? (cMPartial ? na : cMH) : cPMH
kPML := newMonth ? (cMPartial ? na : cML) : cPML
kMO := newMonth ? lv.o : cMO
kOpen := evOpen ? lv.o : na
// expected move: the method the frequencies were measured with, unless the user chooses
float iv = f_ivFor(cKey)
if ivManual > 0 and last_bar_time - time <= 4 * 86400000
iv := ivManual
bool wantIv = emMode == "Volatilidad implícita" or (emMode == "Auto" and (stats.ok ? stats.method == "implied" : hasIv))
float emIv = na(iv) or na(cC) ? na : 0.8 * cC * iv / 100.0 / math.sqrt(252)
float emAtr = na(cAtr) ? na : 0.88 * cAtr
bool usedIv = wantIv and not na(emIv)
kEM := math.round_to_mintick(usedIv ? emIv : emAtr)
kMethod := usedIv ? "iv" : na(emAtr) ? "" : "atr"
kIv := usedIv ? iv : na
for i = 0 to 4
float r = RUNGS.get(i)
bool has = not na(kEM) and kEM > 0
cRungUp.set(i, has and not na(kPC) ? math.round_to_mintick(kPC + r * kEM) : na)
cRungDn.set(i, has and not na(kPC) ? math.round_to_mintick(kPC - r * kEM) : na)
rungUp.set(i, has and not na(kOpen) ? math.round_to_mintick(kOpen + r * kEM) : na)
rungDn.set(i, has and not na(kOpen) ? math.round_to_mintick(kOpen - r * kEM) : na)
if evOwnOpen or (evFin and not own.active)
kORH := na
kORL := na
kIBH := na
kIBL := na
if evOr
kORH := own.orH
kORL := own.orL
if evIb
kIBH := own.ibH
kIBL := own.ibL
// ----------------------------------------------------------------------------------------------------------- drawing
type Lvl
float price
string name
color col
int sty = 0
int wid = 1
int x1 = 0
string tip = ""
f_add(array<Lvl> a, bool show, float p, string name, color col, int sty, int wid, int x1, string tip) =>
if show and not na(p)
a.push(Lvl.new(p, name, col, sty, wid, x1, tip))
a.size()
f_style(int s) =>
s == 1 ? line.style_dashed : s == 2 ? line.style_dotted : line.style_solid
string txtSize = sizeIn == "tiny" ? size.tiny : sizeIn == "normal" ? size.normal : size.small
string EMU = f_t("ME", "EM", "ME")
string CAVEAT = f_t("Frecuencia medida en sesiones pasadas; no es una señal ni una predicción.", "Frequency measured on past sessions; not a signal or a prediction.", "Frequência medida em sessões passadas; não é um sinal nem uma previsão.")
f_tipOpen(float pct, float n, string through) =>
f_t("Desde la apertura: ", "From the open: ", "Desde a abertura: ") + f_pct(pct) + f_t(" de ", " of ", " de ") + str.tostring(n, "0") + f_t(" sesiones llegaron a esta distancia. Datos al ", " sessions travelled this far. Data through ", " sessões chegaram a esta distância. Dados até ") + through + ". " + CAVEAT
f_tipClose(float pct, float n, string through) =>
f_t("Desde el cierre anterior: ", "From the prior close: ", "Desde o fechamento anterior: ") + f_pct(pct) + f_t(" de ", " of ", " de ") + str.tostring(n, "0") + f_t(" sesiones llegaron a esta distancia. Datos al ", " sessions travelled this far. Data through ", " sessões chegaram a esta distância. Dados até ") + through + ". " + CAVEAT
var array<line> curLines = array.new<line>()
var array<label> curLabels = array.new<label>()
bool rebuild = evOpen or evFin or evOr or evIb or evOwnOpen
bool recent = last_bar_time - time <= drawDays * 86400000
if rebuild and phase > 0
// the drawings of a finished session stay (if asked) when the plan for the next one replaces them
bool keepNow = keepHist and evFin and phase0 == 1
if keepNow
curLines.clear()
curLabels.clear()
else
for ln in curLines
ln.delete()
for lb in curLabels
lb.delete()
curLines.clear()
curLabels.clear()
if recent
int barMs = mult * 60000
int xA = phase == 1 ? lv.startTime : time
int xB = phase == 1 ? lv.startTime + (lvEnd - lvStart) * 60000 : time + barMs
int ownB = own.startTime + (ownEnd - ownStart) * 60000
bool ownLive = own.startTime > 0 and time < ownB and time_close > own.startTime
if phase == 1 and ownLive
xB := math.max(xB, ownB)
int xLab = phase == 1 ? xB : time + labOffset * barMs
int xOwn = ownLive ? own.startTime : xA
string ext = phase == 1 ? extend.none : extend.right
array<Lvl> lvls = array.new<Lvl>()
f_add(lvls, showPrior, kPH, f_t("Máx. ant.", "Prior high", "Máx. ant."), cPrior, 0, 1, xA, "")
f_add(lvls, showPrior, kPL, f_t("Mín. ant.", "Prior low", "Mín. ant."), cPrior, 0, 1, xA, "")
f_add(lvls, showPrior, kPC, f_t("Cierre ant.", "Prior close", "Fech. ant."), cPrior, 1, 1, xA, "")
f_add(lvls, showMid, kMid, f_t("Medio ant.", "Prior mid", "Meio ant."), cPrior, 2, 1, xA, "")
f_add(lvls, showValue, kVAH, "VAH", cValue, 0, 1, xA, f_t("Borde superior del área de valor (70 %) de la sesión anterior, perfil de 30 minutos.", "Upper edge of the prior session's 70% value area, 30-minute profile.", "Borda superior da área de valor (70 %) da sessão anterior, perfil de 30 minutos."))
f_add(lvls, showValue, kVAL, "VAL", cValue, 0, 1, xA, f_t("Borde inferior del área de valor (70 %) de la sesión anterior.", "Lower edge of the prior session's 70% value area.", "Borda inferior da área de valor (70 %) da sessão anterior."))
f_add(lvls, showValue, kPOC, "POC", cValue, 1, 2, xA, f_t("Fila con más periodos de 30 minutos de la sesión anterior.", "Row with the most 30-minute periods of the prior session.", "Linha com mais períodos de 30 minutos da sessão anterior."))
f_add(lvls, showWeek, kPWH, f_t("Máx. sem. ant.", "Prior week high", "Máx. sem. ant."), cWeek, 0, 1, xA, "")
f_add(lvls, showWeek, kPWL, f_t("Mín. sem. ant.", "Prior week low", "Mín. sem. ant."), cWeek, 0, 1, xA, "")
f_add(lvls, showCurWeek, kWO, f_t("Apert. semana", "Week open", "Abert. semana"), cWeek, 2, 1, xA, "")
f_add(lvls, showCurWeek, kCWH, f_t("Máx. semana", "Week high", "Máx. semana"), cWeek, 1, 1, xA, f_t("Máximo de la semana en curso hasta la sesión anterior.", "High of the current week through the prior session.", "Máxima da semana em curso até a sessão anterior."))
f_add(lvls, showCurWeek, kCWL, f_t("Mín. semana", "Week low", "Mín. semana"), cWeek, 1, 1, xA, f_t("Mínimo de la semana en curso hasta la sesión anterior.", "Low of the current week through the prior session.", "Mínima da semana em curso até a sessão anterior."))
f_add(lvls, showMonth, kPMH, f_t("Máx. mes ant.", "Prior month high", "Máx. mês ant."), cMonth, 0, 1, xA, "")
f_add(lvls, showMonth, kPML, f_t("Mín. mes ant.", "Prior month low", "Mín. mês ant."), cMonth, 0, 1, xA, "")
f_add(lvls, showMonth, kMO, f_t("Apert. mes", "Month open", "Abert. mês"), cMonth, 2, 1, xA, "")
f_add(lvls, showOR, kORH, f_t("RA máx.", "OR high", "RA máx."), cOR, 0, 1, xOwn, "")
f_add(lvls, showOR, kORL, f_t("RA mín.", "OR low", "RA mín."), cOR, 0, 1, xOwn, "")
f_add(lvls, showIB, kIBH, f_t("IB máx.", "IB high", "IB máx."), cIB, 0, 2, xOwn, "")
f_add(lvls, showIB, kIBL, f_t("IB mín.", "IB low", "IB mín."), cIB, 0, 2, xOwn, "")
f_add(lvls, phase == 1 and showLadder, kOpen, f_t("Apertura", "Open", "Abertura"), cPrior, 2, 1, xA, "")
for i = 0 to 4
string rs = f_rung(RUNGS.get(i)) + " " + EMU
// from the open, once the session has one
if phase == 1 and showLadder
f_add(lvls, true, rungUp.get(i), "+" + rs + (statsOn ? " " + f_pct(f_at(stats.openUp, i)) : ""), cUp, 2, 1, xA, statsOn ? f_tipOpen(f_at(stats.openUp, i), stats.n, stats.through) : "")
f_add(lvls, true, rungDn.get(i), "−" + rs + (statsOn ? " " + f_pct(f_at(stats.openDn, i)) : ""), cDn, 2, 1, xA, statsOn ? f_tipOpen(f_at(stats.openDn, i), stats.n, stats.through) : "")
// from the prior close: the whole ladder before the open, the band (1 EM) always
bool isBand = i == 3
if (phase == 2 and (showLadder or (isBand and showObj))) or (phase == 1 and ((isBand and showObj) or showCloseLadder))
string nm = f_t("cierre", "close", "fech.")
f_add(lvls, true, cRungUp.get(i), nm + " +" + rs + (statsOn ? " " + f_pct(f_at(stats.closeUp, i)) : ""), cUp, isBand ? 1 : 2, isBand ? 2 : 1, xA, statsOn ? f_tipClose(f_at(stats.closeUp, i), stats.nClose, stats.through) : "")
f_add(lvls, true, cRungDn.get(i), nm + " −" + rs + (statsOn ? " " + f_pct(f_at(stats.closeDn, i)) : ""), cDn, isBand ? 1 : 2, isBand ? 2 : 1, xA, statsOn ? f_tipClose(f_at(stats.closeDn, i), stats.nClose, stats.through) : "")
int m = lvls.size()
if m > 0
array<float> prices = array.new<float>()
for q in lvls
prices.push(q.price)
curLines.push(line.new(q.x1, q.price, xB, q.price, xloc = xloc.bar_time, extend = ext, color = q.col, style = f_style(q.sty), width = q.wid))
array<int> ord = prices.sort_indices(order.descending)
float tol = na(kEM) ? 0.0 : mergePct / 100.0 * kEM
int gi = 0
while gi < m
Lvl a = lvls.get(ord.get(gi))
string txt = a.name
string tip = a.tip
float pTop = a.price
float pBot = a.price
int gj = gi + 1
while gj < m
Lvl b = lvls.get(ord.get(gj))
if pTop - b.price > tol
break
txt += " · " + b.name
if b.tip != ""
tip += (tip == "" ? "" : "\n") + b.tip
pBot := b.price
gj += 1
string ptxt = pBot == pTop ? f_px(pTop) : f_px(pTop) + " – " + f_px(pBot)
curLabels.push(label.new(xLab, (pTop + pBot) / 2, txt + " " + ptxt, xloc = xloc.bar_time, style = label.style_label_left, color = color.new(a.col, 100), textcolor = a.col, size = txtSize, textalign = text.align_left, tooltip = tip))
gi := gj
// ------------------------------------------------------------------------------------------------------------- table
f_pos(string p) =>
p == "top_left" ? position.top_left : p == "bottom_right" ? position.bottom_right : p == "bottom_left" ? position.bottom_left : p == "middle_right" ? position.middle_right : position.top_right
var table info = na
f_cell(table t, int col, int row, string txt, color tc, string al) =>
table.cell(t, col, row, txt, text_color = tc, text_size = size.small, text_halign = al)
true
if barstate.islast and showTable
// a fresh table on every update: merged cells are defined once per table
if not na(info)
table.delete(info)
info := table.new(f_pos(tablePos), 7, 12, bgcolor = cTableBg, border_width = 0)
color dim = color.new(cText, 35)
if not okTf
f_cell(info, 0, 0, f_t("Usa un gráfico de 1 a 60 minutos.", "Use a chart of 1 to 60 minutes.", "Use um gráfico de 1 a 60 minutos."), cText, text.align_left)
else
string head = f_t("Niveles clave · ", "Key levels · ", "Níveis-chave · ") + root + (statsOn ? f_t(" · datos al ", " · data through ", " · dados até ") + stats.through + " · n = " + str.tostring(stats.n, "0") : f_t(" · sin frecuencias para este mercado o sesión", " · no frequencies for this market or session", " · sem frequências para este mercado ou sessão"))
f_cell(info, 0, 0, head, cText, text.align_left)
table.merge_cells(info, 0, 0, 6, 0)
string how = kMethod == "iv" ? f_t("volatilidad implícita ", "implied volatility ", "volatilidade implícita ") + str.tostring(kIv, "0.0#") : kMethod == "atr" ? "0.88 × ATR20" + (cTrN < 20 ? f_t(" (solo ", " (only ", " (só ") + str.tostring(cTrN) + f_t(" sesiones)", " sessions)", " sessões)") : "") : f_t("sin historia suficiente", "not enough history", "sem histórico suficiente")
string emTxt = f_t("Rango esperado de hoy: ±", "Today's expected move: ±", "Movimento esperado de hoje: ±") + f_px(kEM) + " (" + how + ")"
f_cell(info, 0, 1, emTxt, cText, text.align_left)
table.merge_cells(info, 0, 1, 6, 1)
bool live = phase == 1
int elapsedMin = live ? lv.elapsed : 0
bool over = live and (not lv.active or elapsedMin >= stats.total)
int mk = statsOn and live and not over ? f_markAt(stats, elapsedMin) : -1
string anchor = live ? f_t("desde la apertura ", "from the open ", "desde a abertura ") + f_px(kOpen) : f_t("antes de la apertura: desde el cierre ", "before the open: from the close ", "antes da abertura: desde o fechamento ") + f_px(kPC)
f_cell(info, 0, 2, anchor, dim, text.align_left)
table.merge_cells(info, 0, 2, 6, 2)
string nowHdr = mk >= 0 ? f_t("queda (", "left (", "resta (") + f_hhmm(lvStart + int(f_at(stats.marks, mk))) + ")" : f_t("estado", "status", "estado")
f_cell(info, 0, 3, EMU, dim, text.align_left)
f_cell(info, 1, 3, "▲", cUp, text.align_right)
f_cell(info, 2, 3, f_t("medido", "measured", "medido"), dim, text.align_right)
f_cell(info, 3, 3, nowHdr, dim, text.align_right)
f_cell(info, 4, 3, "▼", cDn, text.align_right)
f_cell(info, 5, 3, f_t("medido", "measured", "medido"), dim, text.align_right)
f_cell(info, 6, 3, nowHdr, dim, text.align_right)
string sReached = f_t("alcanzado", "reached", "atingido")
for i = 0 to 4
float pu = live ? rungUp.get(i) : cRungUp.get(i)
float pd = live ? rungDn.get(i) : cRungDn.get(i)
bool ru = live and not na(pu) and lv.h >= pu
bool rd = live and not na(pd) and lv.l <= pd
float mu = statsOn ? (live ? f_at(stats.openUp, i) : f_at(stats.closeUp, i)) : na
float md = statsOn ? (live ? f_at(stats.openDn, i) : f_at(stats.closeDn, i)) : na
string su = ru ? sReached : over ? "—" : mk >= 0 ? f_pct(f_left(stats, true, i, elapsedMin)) : "·"
string sd = rd ? sReached : over ? "—" : mk >= 0 ? f_pct(f_left(stats, false, i, elapsedMin)) : "·"
f_cell(info, 0, 4 + i, f_rung(RUNGS.get(i)), cText, text.align_left)
f_cell(info, 1, 4 + i, f_px(pu), ru ? cUp : cText, text.align_right)
f_cell(info, 2, 4 + i, f_pct(mu), cText, text.align_right)
f_cell(info, 3, 4 + i, su, ru ? cUp : cText, text.align_right)
f_cell(info, 4, 4 + i, f_px(pd), rd ? cDn : cText, text.align_right)
f_cell(info, 5, 4 + i, f_pct(md), cText, text.align_right)
f_cell(info, 6, 4 + i, sd, rd ? cDn : cText, text.align_right)
if statsOn and stats.marks.size() >= 7
// the clock: what was left for 0.5 expected moves when it had not been reached by three times of the day
string ck = f_t("Si 0,5 ME no llegó a las ", "If 0.5 EM was not reached by ", "Se 0,5 ME não chegou às ")
string upS = ""
string dnS = ""
string hrs = ""
array<int> pick = array.from(1, 4, 6)
for j in pick
int mm = int(f_at(stats.marks, j))
hrs += (hrs == "" ? "" : " / ") + f_hhmm(lvStart + mm)
upS += (upS == "" ? "" : " / ") + f_pct(f_left(stats, true, 1, mm))
dnS += (dnS == "" ? "" : " / ") + f_pct(f_left(stats, false, 1, mm))
f_cell(info, 0, 9, ck + hrs + f_t(", quedó: ▲ ", ", what was left: ▲ ", ", restou: ▲ ") + upS + " ▼ " + dnS, dim, text.align_left)
table.merge_cells(info, 0, 9, 6, 9)
string sessTxt = f_t("Sesión ", "Session ", "Sessão ") + lvSpec + " (" + lvTz + "). " + CAVEAT
f_cell(info, 0, 10, sessTxt, dim, text.align_left)
table.merge_cells(info, 0, 10, 6, 10)
// ------------------------------------------------------------------------------------------------------------ alerts
f_touch(float p) =>
not na(p) and high >= p and low <= p
alertcondition(f_touch(kPH), "Prior session high", "Precio en el máximo de la sesión anterior / price at the prior session high")
alertcondition(f_touch(kPL), "Prior session low", "Precio en el mínimo de la sesión anterior / price at the prior session low")
alertcondition(f_touch(kPC), "Prior session close", "Precio en el cierre de la sesión anterior / price at the prior session close")
alertcondition(f_touch(kVAH), "Prior value area high", "Precio en el VAH de la sesión anterior / price at the prior value area high")
alertcondition(f_touch(kVAL), "Prior value area low", "Precio en el VAL de la sesión anterior / price at the prior value area low")
alertcondition(f_touch(kPOC), "Prior POC", "Precio en el POC de la sesión anterior / price at the prior point of control")
alertcondition(f_touch(kPWH), "Prior week high", "Precio en el máximo de la semana anterior / price at the prior week high")
alertcondition(f_touch(kPWL), "Prior week low", "Precio en el mínimo de la semana anterior / price at the prior week low")
alertcondition(f_touch(kPMH), "Prior month high", "Precio en el máximo del mes anterior / price at the prior month high")
alertcondition(f_touch(kPML), "Prior month low", "Precio en el mínimo del mes anterior / price at the prior month low")
alertcondition(f_touch(kORH), "Opening range high", "Precio en el máximo del rango de apertura / price at the opening range high")
alertcondition(f_touch(kORL), "Opening range low", "Precio en el mínimo del rango de apertura / price at the opening range low")
alertcondition(f_touch(kIBH), "Initial balance high", "Precio en el máximo del balance inicial / price at the initial balance high")
alertcondition(f_touch(kIBL), "Initial balance low", "Precio en el mínimo del balance inicial / price at the initial balance low")
alertcondition(f_touch(cRungUp.get(3)), "Expected move band, upper (close + 1 EM)", "Precio en la banda superior del rango esperado / price at the upper expected-move band")
alertcondition(f_touch(cRungDn.get(3)), "Expected move band, lower (close - 1 EM)", "Precio en la banda inferior del rango esperado / price at the lower expected-move band")
alertcondition(f_touch(rungUp.get(0)), "Open + 0.25 EM", "Precio en apertura + 0,25 ME / price at open + 0.25 EM")
alertcondition(f_touch(rungUp.get(1)), "Open + 0.5 EM", "Precio en apertura + 0,5 ME / price at open + 0.5 EM")
alertcondition(f_touch(rungUp.get(2)), "Open + 0.75 EM", "Precio en apertura + 0,75 ME / price at open + 0.75 EM")
alertcondition(f_touch(rungUp.get(3)), "Open + 1 EM", "Precio en apertura + 1 ME / price at open + 1 EM")
alertcondition(f_touch(rungUp.get(4)), "Open + 1.5 EM", "Precio en apertura + 1,5 ME / price at open + 1.5 EM")
alertcondition(f_touch(rungDn.get(0)), "Open - 0.25 EM", "Precio en apertura − 0,25 ME / price at open − 0.25 EM")
alertcondition(f_touch(rungDn.get(1)), "Open - 0.5 EM", "Precio en apertura − 0,5 ME / price at open − 0.5 EM")
alertcondition(f_touch(rungDn.get(2)), "Open - 0.75 EM", "Precio en apertura − 0,75 ME / price at open − 0.75 EM")
alertcondition(f_touch(rungDn.get(3)), "Open - 1 EM", "Precio en apertura − 1 ME / price at open − 1 EM")
alertcondition(f_touch(rungDn.get(4)), "Open - 1.5 EM", "Precio en apertura − 1,5 ME / price at open − 1.5 EM")