本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © lucymatos
//@version=6
indicator("Strat · HTF", overlay = true, max_boxes_count = 500, max_lines_count = 500, max_labels_count = 500)
// ---------------------------------------------------------------------
// INPUTS
// ---------------------------------------------------------------------
grpSetup = "Setups"
pmgN = input.int(3, "PMG run length", minval = 2, maxval = 4, group = grpSetup, tooltip = "How many consecutive directional bars (all lower-lows or all higher-highs) before a Pivot Machine Gun reversal is flagged.")
e22 = input.bool(true, "2-2 reversal", group = grpSetup)
e212 = input.bool(true, "2-1-2 (rev + cont)", group = grpSetup)
e312 = input.bool(true, "3-1-2", group = grpSetup)
e122 = input.bool(true, "1-2-2 (rev strat)", group = grpSetup)
e322 = input.bool(true, "3-2-2", group = grpSetup)
ePMG = input.bool(true, "PMG", group = grpSetup)
grpDash = "Dashboard"
showDash = input.bool(true, "Show dashboard", group = grpDash)
liveFtfc = input.bool(false, "Live FTFC (price vs TF open)", group = grpDash, tooltip = "Dir column uses current price vs each timeframe's OPEN — the canonical Strat FTFC. Repaints intrabar. Off = last closed candle direction (stable, no repaint).")
showAlign = input.bool(true, "Continuity column (setup vs FTFC)", group = grpDash, tooltip = "Adds a ± column marking whether each timeframe's setup points WITH the overall timeframe continuity (✓) or against it (✗).")
showStats = input.bool(true, "Historical stats columns (NQ study)", group = grpDash, tooltip = "Adds 1st% | n | +1R% | CB% | Risk% for each row's current pattern, from a 1-minute-path study of NQ (2019-06-02 to 2025-03-14). 1st% = how often the displayed side of the setup bar breaks first. n = historical trades. +1R% = share reaching +1R before the stop (of those that resolved, 3-bar window). CB% = share where the trigger bar closed beyond the trigger level. Risk% = median entry-to-stop distance as % of price. Hover any cell for the baseline and significance. Descriptive history, not a forecast: most cells are indistinguishable from their baseline after multiple-testing correction, and ↑/↓ marks flag the exceptions (weak evidence: consecutive events overlap). TRIGGERED rows show n and Risk% only, because the trigger bar has already played. Assumes a back-adjusted continuous NQ contract and HTF bars that open at 18:00 ET (CME session); other bar boundaries or unadjusted roll gaps will change which patterns appear.")
statsAnySym = input.bool(false, "Show stats on non-NQ symbols", group = grpDash, tooltip = "The numbers were measured on NQ only. Leave off unless you accept applying them to another instrument.")
dashV = input.string("Top", "Position", options = ["Top","Middle","Bottom"], inline = "loc", group = grpDash)
dashH = input.string("Right", "", options = ["Left","Center","Right"], inline = "loc", group = grpDash)
dashSize = input.string("Small", "Text size", options = ["Tiny","Small","Normal","Large"], group = grpDash)
dashMono = input.bool(true, "Monospace font", group = grpDash)
dashText = input.color(#000000, "Primary text", inline = "t1", group = grpDash)
dashMuted = input.color(#9a9a9a, "Muted text", inline = "t1", group = grpDash)
dashBg = input.color(#ffffff, "Cell bg", inline = "b1", group = grpDash)
dashHeadBg = input.color(#ececec, "Header bg", inline = "b1", group = grpDash)
dashUp = input.color(#26a69a, "Up / Down", inline = "ud", group = grpDash)
dashDown = input.color(#ef5350, "", inline = "ud", group = grpDash)
dashInPlay = input.color(#f7a325, "In play", group = grpDash)
dashOnColor = input.color(#ffffff, "Text on colour", group = grpDash, tooltip = "Text colour used inside coloured cells (Dir, TRIGGERED, aligned banner).")
dashBorder = input.color(#c8c8c8, "Border", inline = "br", group = grpDash)
dashBorderW = input.int(1, "", minval = 0, maxval = 4, inline = "br", group = grpDash)
dashFrame = input.color(#b0b0b0, "Frame", inline = "fr", group = grpDash)
dashFrameW = input.int(1, "", minval = 0, maxval = 4, inline = "fr", group = grpDash)
grpOv = "HTF Overlay"
overlaySel = input.string("None", "Overlay TF", options = ["None","15m","30m","1h","4h","1D","1W"], group = grpOv, tooltip = "Draw this timeframe's candles as a floating candlestick cluster to the RIGHT of price. Must be >= your chart timeframe.")
overlayCount = input.int(10, "Candles to draw", minval = 2, maxval = 40, group = grpOv)
ovOffset = input.int(8, "Offset from price", minval = 1, group = grpOv, tooltip = "Bars of gap between the last real bar and the floating cluster.")
ovSpacing = input.int(4, "Candle spacing", minval = 3, maxval = 12, group = grpOv)
ovFit = input.bool(true, "Auto-fit height", group = grpOv, tooltip = "Scale the cluster to a sensible height relative to chart candles, regardless of overlay TF. Preserves candle proportions.")
ovFitMult = input.float(25, "Auto-fit target (ATRs)", minval = 5, maxval = 80, step = 5, group = grpOv, tooltip = "Target cluster height as a multiple of the chart's ATR(14).")
ovScale = input.float(0.5, "Manual height scale", minval = 0.1, maxval = 1.0, step = 0.05, group = grpOv, tooltip = "Used when Auto-fit is off. 1 = true price height, lower = shorter.")
showOvLabels = input.bool(true, "Strat number labels", group = grpOv)
showOvSetups = input.bool(true, "Setup labels", group = grpOv)
ovBull = input.color(#26a69a, "Body up / down", inline = "ovb", group = grpOv)
ovBear = input.color(#ef5350, "", inline = "ovb", group = grpOv)
ovBorder = input.color(#787b86, "Border / wick", inline = "ovc", group = grpOv)
ovWick = input.color(#787b86, "", inline = "ovc", group = grpOv)
ovLblTx = input.color(#e0e0e0, "Number text", group = grpOv)
ovSetBull = input.color(#26a69a, "Setup text up / down", inline = "ovs", group = grpOv)
ovSetBear = input.color(#ef5350, "", inline = "ovs", group = grpOv)
showDividers = input.bool(true, "TF dividers on price chart", group = grpOv, tooltip = "Vertical lines on the real price chart at each overlay-TF boundary, so you can see where each HTF candle begins and ends — at true price, no scaling.")
divCol = input.color(color.new(#787b86, 55), "Divider colour", inline = "div", group = grpOv)
divStyle = input.string("Dotted", "", options = ["Solid","Dashed","Dotted"], inline = "div", group = grpOv)
divWidth = input.int(1, "", minval = 1, maxval = 3, inline = "div", group = grpOv)
divCount = input.int(20, "Dividers to keep", minval = 2, maxval = 60, group = grpOv)
grpLv = "Levels"
showLevels = input.bool(true, "Draw entry / stop levels", group = grpLv, tooltip = "Entry/stop are drawn for the timeframe selected as 'Overlay TF' in the HTF Overlay group (same TF as the floating candles).")
lvUpCol = input.color(#26a69a, "Long trig / short stop", group = grpLv)
lvDnCol = input.color(#ef5350, "Short trig / long stop", group = grpLv)
lvWidth = input.int(1, "Line width", minval = 1, maxval = 3, group = grpLv)
lvExtend = input.int(30, "Extend (bars)", minval = 5, maxval = 200, group = grpLv)
// ---------------------------------------------------------------------
// HELPERS
// ---------------------------------------------------------------------
tfMins(string tf) =>
switch tf
"D" => 1440
"1D" => 1440
"W" => 10080
"1W" => 10080
"M" => 43200
"1M" => 43200
=> int(str.tonumber(tf))
tfLabel(string tf) =>
switch tf
"15" => "15m"
"30" => "30m"
"60" => "1h"
"240"=> "4h"
"1D" => "1D"
"D" => "1D"
"1W" => "1W"
"W" => "1W"
=> tf
tablePos(string v, string h) =>
switch v + "-" + h
"Top-Left" => position.top_left
"Top-Center" => position.top_center
"Top-Right" => position.top_right
"Middle-Left" => position.middle_left
"Middle-Center" => position.middle_center
"Middle-Right" => position.middle_right
"Bottom-Left" => position.bottom_left
"Bottom-Center" => position.bottom_center
"Bottom-Right" => position.bottom_right
=> position.top_right
// Strat classification vs the prior bar.
// 1 = inside, 2 = 2U (took high only), -2 = 2D (took low only), 3 = outside
stratCode(float h, float l, float ph, float pl) =>
bool up = h > ph
bool dn = l < pl
up and dn ? 3 : up ? 2 : dn ? -2 : 1
typeStr(int c) => c == 3 ? "3" : c == 2 ? "2U" : c == -2 ? "2D" : "1"
lineStyle(string s) => s == "Dashed" ? line.style_dashed : s == "Dotted" ? line.style_dotted : line.style_solid
// Compress a price around a midpoint by factor k (1 = true price, <1 = shorter).
scaleY(float v, float mid, float k) => mid + (v - mid) * k
// chart ATR, used to auto-size the floating HTF cluster (computed every bar)
chartAtr = ta.atr(14)
// ---------------------------------------------------------------------
// SETUP DETECTION — all from CLOSED HTF bars
// ---------------------------------------------------------------------
// Completed pattern whose TRIGGER bar is c1 (the newest / last closed bar).
completedSetup(int c1, int c2, int c3, int c4, int c5) =>
string nm = ""
int dr = 0
int runD = c2 == -2 ? (c3 == -2 ? (c4 == -2 ? (c5 == -2 ? 4 : 3) : 2) : 1) : 0
int runU = c2 == 2 ? (c3 == 2 ? (c4 == 2 ? (c5 == 2 ? 4 : 3) : 2) : 1) : 0
if ePMG and c1 == 2 and runD >= pmgN
nm := "PMG"
dr := 1
else if ePMG and c1 == -2 and runU >= pmgN
nm := "PMG"
dr := -1
else if c2 == 1 and c3 == 3 and math.abs(c1) == 2 and e312
nm := "3-1-2"
dr := c1 == 2 ? 1 : -1
else if c2 == 1 and math.abs(c3) == 2 and math.abs(c1) == 2 and e212
bool cont = (c1 == 2 and c3 == 2) or (c1 == -2 and c3 == -2)
nm := cont ? "2-1-2c" : "2-1-2r"
dr := c1 == 2 ? 1 : -1
else if c3 == 3 and math.abs(c2) == 2 and math.abs(c1) == 2 and c1 * c2 < 0 and e322
nm := "3-2-2"
dr := c1 == 2 ? 1 : -1
else if c3 == 1 and math.abs(c2) == 2 and math.abs(c1) == 2 and c1 * c2 < 0 and e122
nm := "1-2-2"
dr := c1 == 2 ? 1 : -1
else if math.abs(c1) == 2 and math.abs(c2) == 2 and c1 * c2 < 0 and e22
nm := "2-2"
dr := c1 == 2 ? 1 : -1
[nm, dr]
// Setup PRIMED by the last closed bar (it is the setup bar S; the trigger bar has not happened yet).
primedSetup(int t1, int t2, int t3, int t4, int t5, float e1h, float e1l, int ftfc) =>
string name = ""
int dir = 0
float trig = na
int runDown = t1 == -2 ? (t2 == -2 ? (t3 == -2 ? (t4 == -2 ? 4 : 3) : 2) : 1) : 0
int runUp = t1 == 2 ? (t2 == 2 ? (t3 == 2 ? (t4 == 2 ? 4 : 3) : 2) : 1) : 0
if ePMG and runDown >= pmgN
name := "PMG"
dir := 1
trig := e1h
else if ePMG and runUp >= pmgN
name := "PMG"
dir := -1
trig := e1l
else if t1 == 1
if t2 == 3 and e312
name := "3-1-2"
else if math.abs(t2) == 2 and e212
name := "2-1-2"
if name != ""
dir := ftfc >= 0 ? 1 : -1
trig := dir == 1 ? e1h : e1l
else if math.abs(t1) == 2
if t2 == 3 and e322
name := "3-2-2"
else if t2 == 1 and e122
name := "1-2-2"
else if e22
name := "2-2"
if name != ""
dir := t1 == 2 ? -1 : 1 // reversal of the last closed bar
trig := dir == 1 ? e1h : e1l
if name == "2-1-2"
bool cont = (dir == 1 and t2 == 2) or (dir == -1 and t2 == -2)
name := cont ? "2-1-2c" : "2-1-2r"
[name, dir, trig]
// Dashboard setup for one TF (closed bars only).
// Returns the row's state plus the in-play setup the SAME closed bar creates, which is hidden whenever that
// bar also completed a pattern (status 2) - the dashboard shows it beside TRIGGERED.
dashSetup(int t1, int t2, int t3, int t4, int t5, float e1h, float e1l, float e2h, float e2l, int ftfc) =>
string name = ""
int dir = 0
float trig = na
int status = 0 // 0 none · 1 in play · 2 triggered
[pn, pd, pg] = primedSetup(t1, t2, t3, t4, t5, e1h, e1l, ftfc)
// Phase 1 — did the last closed bar just TRIGGER a completed setup?
[cn, cd] = completedSetup(t1, t2, t3, t4, t5)
if cn != ""
name := cn
dir := cd
trig := cd == 1 ? e2h : e2l // the level the trigger bar broke
status := 2
else if pn != ""
name := pn
dir := pd
trig := pg
status := 1
[name, dir, trig, status, pn, pd]
// ---------------------------------------------------------------------
// PER-TF FETCH + PROCESS (closed bars only → no intrabar repaint)
// ---------------------------------------------------------------------
rowTF(simple string tf) =>
[o1, c1, h1, l1, h2, l2, h3, l3, h4, l4, h5, l5, h6, l6, h7, l7, o0, c0] = request.security(syminfo.tickerid, tf, [open[1], close[1], high[1], low[1], high[2], low[2], high[3], low[3], high[4], low[4], high[5], low[5], high[6], low[6], high[7], low[7], open, close], lookahead = barmerge.lookahead_off)
int t1 = stratCode(h1, l1, h2, l2)
int t2 = stratCode(h2, l2, h3, l3)
int t3 = stratCode(h3, l3, h4, l4)
int t4 = stratCode(h4, l4, h5, l5)
int t5 = stratCode(h5, l5, h6, l6)
int ftfcClosed = c1 > o1 ? 1 : c1 < o1 ? -1 : 0 // last closed candle direction (stable)
int ftfcLive = c0 > o0 ? 1 : c0 < o0 ? -1 : 0 // live: price vs developing TF open
int ftfcDisp = liveFtfc ? ftfcLive : ftfcClosed
[nm, sd, tg, st, pn, pd] = dashSetup(t1, t2, t3, t4, t5, h1, l1, h2, l2, ftfcClosed)
float sH = st == 2 ? h2 : h1 // SETUP bar high/low (for TRIGGERED the setup bar is the one before the trigger bar)
float sL = st == 2 ? l2 : l1
string seq = typeStr(t3) + "·" + typeStr(t2) + "·" + typeStr(t1)
[ftfcDisp, seq, nm, sd, tg, st, sH, sL, t1, t2, t3, pn, pd]
[d15, s15, n15, r15, g15, u15, hi15, lo15, k1_15, k2_15, k3_15, pn_15, pd_15] = rowTF("15")
[d30, s30, n30, r30, g30, u30, hi30, lo30, k1_30, k2_30, k3_30, pn_30, pd_30] = rowTF("30")
[d60, s60, n60, r60, g60, u60, hi60, lo60, k1_60, k2_60, k3_60, pn_60, pd_60] = rowTF("60")
[d24, s24, n24, r24, g24, u24, hi24, lo24, k1_24, k2_24, k3_24, pn_24, pd_24] = rowTF("240")
[dD, sD, nD, rD, gD, uD, hiD, loD, k1_D, k2_D, k3_D, pn_D, pd_D ] = rowTF("1D")
[dW, sW, nW, rW, gW, uW, hiW, loW, k1_W, k2_W, k3_W, pn_W, pd_W ] = rowTF("1W")
// collect
var array<string> tfCodes = array.from("15", "30", "60", "240", "1D", "1W")
dirs = array.from(d15, d30, d60, d24, dD, dW)
seqs = array.from(s15, s30, s60, s24, sD, sW)
names = array.from(n15, n30, n60, n24, nD, nW)
sdirs = array.from(r15, r30, r60, r24, rD, rW)
trigs = array.from(g15, g30, g60, g24, gD, gW)
stats = array.from(u15, u30, u60, u24, uD, uW)
hi1s = array.from(hi15, hi30, hi60, hi24, hiD, hiW)
lo1s = array.from(lo15, lo30, lo60, lo24, loD, loW)
k1s = array.from(k1_15, k1_30, k1_60, k1_24, k1_D, k1_W)
k2s = array.from(k2_15, k2_30, k2_60, k2_24, k2_D, k2_W)
k3s = array.from(k3_15, k3_30, k3_60, k3_24, k3_D, k3_W)
pns = array.from(pn_15, pn_30, pn_60, pn_24, pn_D, pn_W)
pds = array.from(pd_15, pd_30, pd_60, pd_24, pd_D, pd_W)
// ---------------------------------------------------------------------
// tf -> array index (for the per-TF arrays above)
// ---------------------------------------------------------------------
tfStatIdx(string code) =>
switch code
"15" => 0
"30" => 1
"60" => 2
"1h" => 2
"240" => 3
"1D" => 4
"D" => 4
"1W" => 5
"W" => 5
=> -1
// ---------------------------------------------------------------------
// HISTORICAL STATS (NQ, 1-min path study, 2019-06-02 to 2025-03-14)
// ---------------------------------------------------------------------
parseStat(string s) =>
array<float> out = array.new<float>()
for p in str.split(s, ",")
array.push(out, str.tonumber(p))
out
var array<float> stN = array.concat(array.concat(parseStat("952,854,4482,2615,2555,3808,1370,1380,3532,4047,12346,8138,4435,7456,1880,2036,4292,3159,7907,4185,7567,9890,1804,1477,1507,1331,2523,1597,1692,2224,242,210,472,488,2194,1313,1317,1832,753,680,1769,2023,6260,4041,2225,3568,990,1153,2167,1582,3992,2002,3642,4639,930,750,783,688,1363,831,912,1210,119,119,304,224,1189,663,658,895,355,341,930,1044,3129,1954,1073,1751,600,605,1090,735,1922,975,1731,2213,529,412,354,296,734,484,476,594,98,86,129,106,345,186,173,212,120,121,234,225,832,440,262,358,172,204,283,192,399,226,324,461,178,125,76,68,255,119,148,182,82,67,6,3,50,19,16,24,17,21,36,21,210,109,53,78,34,36,38,27,107,37,86,85,19,21,21,12,39,18,33,30,3,3,1,2,7,5,3,4,2,,5,5,48,30,19,15,8,5,6,2,26,7,15,17,3,8,,2,12,3,4,5,4,,7567,8138,3247,3756,1368,1692,3642,4041,1463,1877,632,805,1731,1954,740,855,292,355,324,440,123,197,53,91,86,109,36,49,15,27,15,30,7,16,3,6"), parseStat("776,699,4021,2265,2246,3454,1303,1284,2873,3355,11068,7105,3919,6743,1768,1925,3618,2534,7108,3675,6725,8889,1711,1389,1273,1139,2302,1403,1494,2011,235,199,368,407,1933,1130,1172,1645,704,656,1433,1689,5570,3459,1952,3209,929,1088,1819,1271,3570,1739,3202,4162,890,705,665,531,1192,705,812,1069,110,112,257,189,1071,571,579,775,329,310,746,854,2717,1630,914,1526,552,556,905,605,1687,825,1511,1963,482,385,314,252,667,415,434,517,90,82,92,73,275,139,139,166,98,89,197,174,713,368,217,288,137,168,237,155,338,185,269,400,156,107,68,55,232,103,127,165,70,62,4,2,42,18,13,20,16,19,27,13,178,90,44,74,31,34,25,20,96,30,70,77,18,21,19,11,37,17,27,27,3,3,1,2,5,3,2,4,2,,5,4,46,27,18,13,7,3,6,2,25,5,12,14,3,7,,1,11,1,3,5,4,,6725,7105,2923,3305,1230,1493,3202,3459,1285,1609,566,685,1511,1630,644,718,268,301,269,368,103,168,45,80,70,90,30,37,13,21,12,27,6,14,3,5")), parseStat("626,541,,,,,,,2013,3142,,,,,,,3446,1704,,,,,,,1121,901,,,,,,,301,323,,,,,,,1048,1618,,,,,,,1744,891,,,,,,,578,445,,,,,,,208,158,,,,,,,537,815,,,,,,,867,393,,,,,,,239,207,,,,,,,84,71,,,,,,,140,174,,,,,,,220,112,,,,,,,56,43,,,,,,,4,1,,,,,,,20,15,,,,,,,32,15,,,,,,,18,5,,,,,,,,1,,,,,,,,4,,,,,,,6,1,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stN1 = array.concat(array.concat(parseStat("805,752,2867,1955,1784,2563,704,786,2954,3229,7779,5887,3043,4661,876,1048,3314,2689,4706,3051,4885,6449,813,760,1176,1056,1486,1139,1084,1392,81,98,391,414,1380,948,909,1221,379,374,1445,1613,3964,2919,1573,2299,516,648,1613,1327,2428,1499,2364,3035,422,418,567,532,849,606,598,780,51,59,250,200,804,523,493,646,221,210,744,844,1986,1471,755,1182,307,346,807,601,1205,733,1144,1387,271,234,224,224,401,315,257,352,50,40,117,103,288,176,150,187,89,107,200,194,534,326,187,237,100,120,227,160,231,185,218,299,97,65,39,49,109,72,70,79,34,31,5,3,32,13,14,17,10,15,30,17,138,94,40,47,17,19,33,21,65,30,59,64,7,7,17,12,23,16,25,21,2,1,1,1,5,5,2,3,1,,4,5,36,29,13,12,4,3,3,2,18,7,8,14,0,6,,2,10,2,2,3,0,,4885,5887,2033,2696,856,1194,2364,2919,926,1350,405,586,1144,1471,495,637,199,261,218,326,92,149,38,74,59,94,22,45,10,25,8,29,5,15,1,6"), parseStat("629,597,2406,1605,1475,2209,637,690,2295,2537,6501,4854,2527,3948,764,937,2640,2064,3907,2541,4043,5448,720,672,942,864,1265,945,886,1179,74,87,287,333,1119,765,764,1034,330,350,1109,1279,3274,2337,1300,1940,455,583,1265,1016,2006,1236,1924,2558,382,373,449,375,678,480,498,639,42,52,203,165,686,431,414,526,195,179,560,654,1574,1147,596,957,259,297,622,471,970,583,924,1137,224,207,184,180,334,246,215,275,42,36,80,70,218,129,116,141,67,75,163,143,415,254,142,167,65,84,181,123,170,144,163,238,75,47,31,36,86,56,49,62,22,26,3,2,24,12,11,13,9,13,21,9,106,75,31,43,14,17,20,14,54,23,43,56,6,7,15,11,21,15,19,18,2,1,1,1,3,3,1,3,1,,4,4,34,26,12,10,3,1,3,2,17,5,5,11,0,5,,1,9,0,1,3,0,,4043,4854,1709,2245,718,995,1924,2337,748,1082,339,466,924,1147,399,500,175,207,163,254,72,120,30,63,43,75,16,33,8,19,5,26,4,13,1,5")), parseStat("530,483,,,,,,,1683,2467,,,,,,,2627,1441,,,,,,,860,719,,,,,,,254,275,,,,,,,851,1267,,,,,,,1272,748,,,,,,,403,340,,,,,,,169,139,,,,,,,434,647,,,,,,,619,313,,,,,,,146,152,,,,,,,74,69,,,,,,,118,149,,,,,,,172,94,,,,,,,26,32,,,,,,,4,1,,,,,,,16,12,,,,,,,27,12,,,,,,,14,5,,,,,,,,1,,,,,,,,4,,,,,,,3,1,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stP1 = array.concat(array.concat(parseStat("52.4,50.8,51.2,52.3,51.8,52.4,53.4,51.8,50.1,52.1,49.4,49.8,51.8,51.9,48.6,52.1,51.3,50.8,51.4,51.9,47.7,51.7,51.5,52.5,53.1,54.2,52.2,53.8,49.6,52.4,51.9,60.2,53.7,55.8,51.6,51.3,55.2,54.3,53.6,55.1,53.8,52.1,50.9,48.7,52.6,51.5,51.6,52.8,52.0,50.1,50.2,51.6,47.8,53.5,54.0,50.2,54.3,50.6,52.1,51.8,54.7,51.3,51.0,50.8,53.6,52.0,55.0,53.0,52.1,52.9,53.4,51.4,53.9,49.9,51.7,48.9,56.4,52.8,50.5,54.3,52.4,49.9,48.9,54.6,50.0,51.4,53.1,53.8,56.2,59.8,51.1,51.1,52.5,47.4,52.0,57.5,48.7,46.6,52.4,56.8,50.7,52.4,61.8,51.4,55.5,53.1,53.6,51.8,54.5,50.6,50.0,52.5,47.6,49.4,51.1,50.8,49.5,55.9,55.7,53.8,59.0,42.9,61.5,55.6,48.6,51.9,50.0,51.6,80.0,100.0,43.8,53.8,35.7,41.2,50.0,46.7,53.3,47.1,50.0,53.2,62.5,59.6,35.3,47.4,45.5,33.3,53.8,56.7,50.8,51.6,42.9,42.9,70.6,75.0,47.8,37.5,52.0,42.9,50.0,100.0,100.0,100.0,60.0,0.0,50.0,0.0,100.0,,75.0,60.0,61.1,41.4,69.2,75.0,25.0,33.3,66.7,100.0,55.6,57.1,50.0,42.9,,16.7,,50.0,30.0,0.0,50.0,0.0,,,47.7,49.8,46.6,48.4,44.3,47.7,47.8,48.7,45.7,48.1,45.7,47.1,50.0,48.9,49.7,46.3,55.8,43.3,49.5,51.8,46.7,48.3,47.4,47.3,50.8,53.2,54.5,48.9,40.0,48.0,50.0,41.4,60.0,40.0,100.0,16.7"), parseStat("66.1,63.8,60.3,63.0,62.3,60.3,58.9,58.3,63.2,65.1,58.6,59.9,61.7,60.8,55.4,58.1,63.3,65.0,61.4,61.6,57.1,60.5,57.4,58.6,65.7,64.7,60.8,63.9,60.3,61.2,56.8,66.7,70.0,67.0,62.6,63.0,65.1,63.7,61.2,58.6,67.8,64.3,60.6,60.4,62.4,60.2,58.0,58.0,64.8,63.4,59.9,61.4,58.1,62.5,59.4,56.0,67.3,68.5,63.6,64.4,64.3,61.7,61.9,57.7,64.0,61.8,63.6,62.4,61.4,64.6,60.5,59.2,68.9,62.7,64.1,61.9,70.1,64.5,58.7,62.6,66.1,63.1,59.6,67.8,61.5,62.2,63.8,60.4,66.8,73.3,60.8,64.2,61.9,60.7,57.1,63.9,62.5,62.9,67.0,74.4,63.8,68.1,79.1,69.3,66.3,69.9,68.0,65.0,67.6,70.1,70.8,75.0,59.1,61.0,66.5,61.8,65.6,68.9,70.7,74.5,74.2,55.6,75.6,69.6,69.4,66.1,77.3,61.5,66.7,100.0,58.3,58.3,45.5,53.8,55.6,53.8,71.4,66.7,63.2,66.7,80.6,65.1,42.9,52.9,75.0,50.0,64.8,69.6,69.8,58.9,50.0,42.9,80.0,72.7,52.4,40.0,68.4,50.0,50.0,100.0,100.0,100.0,100.0,0.0,100.0,0.0,100.0,,75.0,75.0,64.7,46.2,75.0,90.0,33.3,100.0,66.7,100.0,58.8,80.0,80.0,54.5,,20.0,,100.0,33.3,,100.0,0.0,,,57.1,59.9,55.0,57.5,52.5,56.8,58.1,60.4,56.1,59.5,54.3,58.8,61.5,61.9,61.4,58.4,62.9,54.1,65.6,65.0,59.7,60.0,60.0,55.6,69.8,66.7,75.0,66.7,50.0,63.2,80.0,46.2,75.0,46.2,100.0,20.0")), parseStat("52.5,48.9,,,,,,,49.9,52.0,,,,,,,51.3,49.6,,,,,,,55.0,56.9,,,,,,,53.1,56.4,,,,,,,54.9,52.9,,,,,,,52.0,49.6,,,,,,,54.8,51.5,,,,,,,55.6,52.5,,,,,,,51.6,49.9,,,,,,,51.7,49.5,,,,,,,57.5,59.2,,,,,,,54.1,43.5,,,,,,,55.9,49.0,,,,,,,45.9,50.0,,,,,,,61.5,40.6,,,,,,,75.0,100.0,,,,,,,50.0,41.7,,,,,,,51.9,33.3,,,,,,,64.3,80.0,,,,,,,,100.0,,,,,,,,50.0,,,,,,,66.7,100.0,,,,,,,,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stCB = array.concat(array.concat(parseStat("52.5,49.6,51.4,49.3,51.2,48.0,51.6,47.2,50.4,49.6,49.3,48.5,52.4,48.2,49.0,45.6,52.1,48.6,51.4,49.3,51.4,47.3,52.2,48.4,53.7,50.8,50.8,51.0,50.7,49.1,52.1,53.3,54.7,50.4,50.2,47.3,54.6,47.5,53.8,50.1,52.6,49.4,50.9,46.4,51.5,46.4,53.1,48.5,53.7,47.6,51.5,47.6,51.2,47.6,50.5,48.5,55.0,48.1,50.7,47.4,53.9,48.8,49.6,48.7,56.2,51.3,54.5,47.4,53.5,47.4,51.3,44.3,52.6,44.6,50.7,43.2,53.8,48.1,51.3,47.8,50.8,44.9,53.4,47.3,51.3,48.6,50.5,51.2,57.6,54.7,55.4,48.1,51.9,49.3,57.1,52.3,49.6,43.4,56.2,54.8,54.3,46.7,59.2,43.8,59.4,50.2,57.3,45.0,55.0,48.3,54.7,45.6,52.7,47.9,54.4,48.7,50.0,51.0,51.1,46.4,51.3,54.4,62.0,42.0,52.7,50.0,56.1,49.3,66.7,66.7,58.0,42.1,43.8,29.2,52.9,52.4,55.6,42.9,51.0,44.0,69.8,42.3,55.9,44.4,50.0,51.9,53.3,54.1,59.3,45.9,73.7,61.9,71.4,58.3,59.0,61.1,51.5,43.3,100.0,33.3,100.0,100.0,57.1,0.0,66.7,25.0,0.0,,80.0,40.0,68.8,50.0,63.2,60.0,25.0,60.0,66.7,100.0,65.4,57.1,60.0,41.2,33.3,50.0,,0.0,50.0,0.0,75.0,60.0,100.0,,51.4,48.5,52.0,48.6,52.9,48.3,51.2,46.4,51.9,47.3,53.0,48.6,51.3,43.2,50.9,43.4,56.2,44.8,50.0,45.0,48.8,40.6,47.2,42.9,59.3,44.0,66.7,42.9,73.3,44.4,60.0,50.0,71.4,43.8,100.0,33.3"), parseStat("62.6,58.5,56.5,56.0,57.4,52.2,54.0,50.4,60.0,58.0,54.3,54.8,58.7,52.6,51.9,47.9,60.7,58.6,56.6,55.1,57.1,51.9,54.8,51.0,62.3,58.6,54.9,57.2,56.7,53.3,53.6,56.3,67.9,58.7,56.2,53.5,60.2,52.4,57.0,52.0,62.0,57.4,56.3,53.3,57.6,50.9,56.1,51.0,62.5,57.4,56.6,53.9,57.1,52.3,52.5,51.1,62.1,58.9,56.8,55.0,60.0,54.4,53.6,51.8,65.0,59.8,59.7,54.5,59.9,54.2,55.0,48.7,63.5,52.8,57.2,50.5,61.8,54.3,55.8,51.4,59.2,52.9,59.0,55.2,57.8,54.0,54.1,54.5,63.1,60.7,60.7,54.7,56.2,55.3,62.2,53.7,67.4,54.8,66.5,68.3,65.5,57.2,72.4,55.1,68.0,61.5,65.4,50.8,61.3,58.3,65.7,52.4,61.6,56.1,62.7,57.3,58.7,58.0,57.7,54.2,55.9,65.5,67.7,47.6,61.4,55.2,62.9,53.2,75.0,100.0,61.9,44.4,53.8,35.0,56.2,57.9,66.7,69.2,59.6,52.2,79.5,44.6,61.3,47.1,68.0,60.0,59.4,66.7,71.4,50.6,77.8,61.9,78.9,63.6,62.2,58.8,63.0,48.1,100.0,33.3,100.0,100.0,60.0,0.0,100.0,25.0,0.0,,80.0,50.0,71.7,55.6,66.7,69.2,28.6,100.0,66.7,100.0,68.0,80.0,75.0,50.0,33.3,57.1,,0.0,54.5,0.0,100.0,60.0,100.0,,57.1,54.8,57.2,54.5,58.3,53.7,57.1,53.3,57.9,54.1,58.1,55.5,57.8,50.5,57.5,50.8,60.1,51.8,58.7,50.8,57.3,45.2,55.6,46.2,71.4,52.2,80.0,56.8,84.6,57.1,75.0,55.6,83.3,50.0,100.0,40.0")), parseStat("52.4,47.9,,,,,,,50.4,49.1,,,,,,,52.5,47.3,,,,,,,54.3,50.7,,,,,,,53.5,49.8,,,,,,,53.5,49.1,,,,,,,53.7,46.9,,,,,,,55.0,49.0,,,,,,,59.1,51.9,,,,,,,51.4,45.5,,,,,,,49.8,46.1,,,,,,,57.7,56.5,,,,,,,54.8,42.3,,,,,,,57.9,48.3,,,,,,,53.6,44.6,,,,,,,53.6,55.8,,,,,,,50.0,100.0,,,,,,,60.0,46.7,,,,,,,53.1,46.7,,,,,,,66.7,40.0,,,,,,,,100.0,,,,,,,,50.0,,,,,,,66.7,100.0,,,,,,,,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stEx = array.concat(array.concat(parseStat("51.1,48.4,51.0,48.5,51.0,48.5,51.0,48.5,50.9,48.5,51.0,48.4,50.9,48.4,51.0,48.5,51.0,48.5,51.0,48.4,51.0,48.4,51.0,48.5,51.0,48.6,51.0,48.5,51.1,48.5,51.1,48.6,52.5,47.5,51.9,47.5,52.0,47.5,52.0,47.7,51.9,47.5,51.9,47.6,51.8,47.6,51.9,47.7,51.8,47.5,51.8,47.5,51.8,47.6,51.8,47.8,51.9,47.7,51.9,47.8,51.9,47.8,51.9,48.0,52.4,47.1,52.5,47.1,52.3,47.0,52.4,47.3,52.6,47.0,52.5,47.0,52.4,47.1,52.5,47.5,52.5,47.0,52.4,47.0,52.4,47.1,52.5,47.5,52.7,47.4,52.6,47.5,52.5,47.6,52.7,47.8,54.6,47.1,54.6,47.4,54.7,47.3,54.1,47.2,55.2,47.9,55.5,48.2,55.1,48.0,55.0,48.0,55.2,48.6,55.4,48.0,55.3,48.4,54.8,47.9,56.6,49.5,56.2,48.9,55.8,48.8,55.6,48.4,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,56.1,46.3,62.6,47.3,62.6,47.3,62.6,47.3,62.6,,62.6,47.3,62.6,47.3,62.6,47.3,62.6,47.3,62.6,47.3,62.6,47.3,62.6,47.3,62.6,47.3,,47.3,62.6,47.3,62.6,47.3,62.6,,51.0,48.4,50.9,48.4,50.9,48.3,51.8,47.6,51.8,47.6,51.8,47.6,52.4,47.0,52.5,47.0,52.5,47.0,55.3,48.2,55.0,48.1,55.1,48.2,56.1,46.3,56.1,46.3,56.1,46.3,62.6,47.3,62.6,47.3,62.6,47.3"), parseStat("56.8,53.8,56.7,54.0,56.7,54.0,56.6,54.0,56.6,54.0,56.7,53.9,56.6,53.9,56.7,54.0,56.6,53.9,56.6,53.9,56.6,53.9,56.7,54.0,56.8,54.1,56.7,54.0,56.8,54.0,56.9,54.1,58.6,53.0,57.9,53.2,58.0,53.2,58.1,53.5,57.8,53.3,57.7,53.4,57.7,53.4,57.8,53.6,57.7,53.2,57.6,53.3,57.6,53.5,57.7,53.7,57.9,53.5,57.8,53.8,57.8,53.7,57.9,54.2,58.1,52.9,58.6,53.0,58.3,53.2,59.0,54.0,58.6,52.9,58.8,53.4,58.8,53.5,59.4,54.5,58.5,53.1,58.8,53.5,58.8,53.6,59.6,54.4,59.1,53.8,59.7,54.3,59.5,54.7,60.8,55.3,62.1,53.7,66.1,58.8,66.3,57.9,66.7,60.0,62.1,55.7,63.4,56.6,64.7,56.2,64.8,57.4,62.5,54.2,64.2,56.9,64.4,55.8,65.0,57.4,62.2,54.3,63.0,55.8,63.2,55.3,63.9,56.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,64.5,52.1,67.3,57.1,67.3,57.1,67.3,57.1,67.3,,67.3,57.1,67.3,57.1,67.3,57.1,67.3,57.1,67.3,57.1,67.3,57.1,67.3,57.1,67.3,57.1,,57.1,67.3,57.1,67.3,57.1,67.3,,56.6,53.9,56.6,53.9,56.6,53.9,57.6,53.4,57.7,53.4,57.6,53.4,58.8,53.4,58.8,53.4,58.8,53.4,64.4,56.6,63.6,56.8,62.6,57.0,64.5,52.1,64.5,52.1,64.5,52.1,67.3,57.1,67.3,57.1,67.3,57.1")), parseStat("51.0,47.9,,,,,,,50.9,48.0,,,,,,,50.9,47.9,,,,,,,51.0,48.2,,,,,,,52.2,46.9,,,,,,,51.6,47.2,,,,,,,51.5,47.2,,,,,,,51.5,47.4,,,,,,,52.7,47.5,,,,,,,52.7,47.1,,,,,,,52.5,47.1,,,,,,,52.7,47.4,,,,,,,56.1,45.8,,,,,,,57.0,46.9,,,,,,,56.8,47.7,,,,,,,58.6,49.2,,,,,,,56.7,45.8,,,,,,,56.7,45.8,,,,,,,56.7,45.8,,,,,,,56.7,45.8,,,,,,,,48.8,,,,,,,,48.8,,,,,,,60.5,48.8,,,,,,,,48.8,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stSt = array.concat(array.concat(parseStat("47.4,52.1,34.3,40.2,38.0,36.0,25.9,29.2,48.3,44.0,34.6,40.0,36.8,32.8,25.1,26.0,42.9,49.5,31.4,39.3,36.5,34.5,23.2,25.9,41.6,41.8,30.6,36.6,34.4,32.4,16.5,19.5,46.6,47.7,34.3,40.4,34.8,34.6,26.0,26.2,45.2,45.8,34.7,41.3,38.7,35.2,27.4,28.6,41.5,49.4,33.3,42.0,37.3,34.6,23.1,29.6,40.0,44.3,33.3,39.4,34.1,34.9,21.8,25.2,45.1,54.5,36.7,46.3,43.1,41.1,33.8,34.9,45.2,50.3,35.4,44.9,38.0,37.9,28.7,29.1,41.8,47.6,36.6,40.0,37.2,34.9,26.3,29.9,32.5,41.9,30.0,36.4,29.4,33.0,28.6,19.8,66.7,73.6,52.5,66.1,64.2,56.1,39.2,55.4,56.8,59.1,36.2,46.4,43.9,39.1,34.3,32.4,53.7,57.3,36.8,49.1,42.9,34.3,28.7,28.8,25.0,45.6,19.3,31.9,25.0,24.2,20.7,22.4,50.0,66.7,40.0,36.8,62.5,41.7,35.3,38.1,50.0,57.1,38.1,48.6,30.8,25.6,32.4,27.8,50.0,51.9,30.8,41.7,36.0,40.0,21.1,19.0,28.6,50.0,41.0,61.1,39.4,40.0,33.3,0.0,0.0,0.0,28.6,100.0,33.3,75.0,0.0,,20.0,60.0,31.2,60.0,26.3,35.7,37.5,40.0,16.7,0.0,34.6,57.1,26.7,50.0,0.0,62.5,,50.0,58.3,66.7,25.0,60.0,0.0,,36.5,40.0,35.8,40.4,37.4,40.2,37.3,41.3,37.6,41.6,38.0,42.9,37.2,44.9,37.0,45.4,32.9,45.1,42.9,46.4,44.7,49.7,39.6,52.7,36.0,48.6,27.8,57.1,40.0,55.6,26.7,60.0,28.6,62.5,0.0,83.3"), parseStat("35.4,41.5,26.8,31.0,29.5,29.4,22.1,23.9,36.4,32.5,27.0,31.2,28.5,25.7,20.3,21.8,32.3,37.0,23.7,30.9,28.6,27.1,19.0,21.2,30.9,32.0,23.9,27.9,25.7,25.3,14.0,15.1,31.5,37.3,25.4,30.7,26.7,27.1,20.9,23.5,32.3,35.1,26.6,31.5,30.1,28.0,22.6,24.3,30.3,37.1,25.4,33.2,28.6,27.1,19.7,25.1,29.3,27.9,23.7,28.5,26.0,26.3,15.5,20.5,35.0,46.0,29.7,37.7,35.3,32.0,28.6,28.4,31.6,39.2,25.6,34.0,27.2,28.8,22.5,22.8,29.9,36.4,27.8,29.1,28.1,26.6,19.1,24.9,23.9,31.7,22.9,25.8,22.6,23.0,22.2,15.9,53.3,61.6,40.4,54.7,55.4,44.0,25.5,39.3,48.7,47.1,25.6,35.9,32.3,24.3,17.5,17.9,44.7,47.1,25.4,37.8,31.2,24.2,18.6,16.8,16.2,32.7,11.3,21.4,12.6,16.4,7.1,16.1,25.0,50.0,28.6,33.3,53.8,30.0,31.2,31.6,33.3,30.8,27.0,37.8,16.3,21.6,25.8,23.5,24.0,35.0,22.9,27.6,21.4,33.8,16.7,19.0,21.1,45.5,37.8,58.8,25.9,33.3,33.3,0.0,0.0,0.0,0.0,100.0,0.0,75.0,0.0,,20.0,50.0,28.3,55.6,22.2,25.0,28.6,0.0,16.7,0.0,32.0,40.0,8.3,38.5,0.0,57.1,,0.0,54.5,0.0,0.0,60.0,0.0,,28.6,31.2,28.7,32.3,30.3,32.2,28.6,31.5,28.9,31.9,30.7,32.8,28.1,34.0,27.6,35.0,26.9,35.2,31.2,35.9,34.0,41.1,28.9,46.2,21.4,37.8,13.3,43.2,30.8,42.9,8.3,55.6,16.7,57.1,0.0,80.0")), parseStat("47.1,53.6,,,,,,,48.0,42.7,,,,,,,42.2,50.0,,,,,,,39.3,39.5,,,,,,,46.5,46.7,,,,,,,44.8,44.4,,,,,,,40.5,49.2,,,,,,,38.2,44.3,,,,,,,42.8,52.5,,,,,,,47.1,49.7,,,,,,,40.6,47.1,,,,,,,31.0,40.6,,,,,,,60.7,76.1,,,,,,,57.9,61.5,,,,,,,52.7,59.8,,,,,,,21.4,51.2,,,,,,,50.0,100.0,,,,,,,50.0,53.3,,,,,,,43.8,53.3,,,,,,,33.3,20.0,,,,,,,,0.0,,,,,,,,50.0,,,,,,,16.7,0.0,,,,,,,,100.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stRk = array.concat(array.concat(parseStat("0.072,0.068,0.118,0.099,0.101,0.123,0.148,0.149,0.083,0.087,0.133,0.116,0.116,0.141,0.179,0.178,0.102,0.091,0.140,0.118,0.137,0.160,0.194,0.190,0.102,0.105,0.144,0.128,0.138,0.167,0.257,0.235,0.102,0.104,0.169,0.138,0.145,0.175,0.216,0.223,0.117,0.124,0.186,0.157,0.160,0.197,0.251,0.255,0.147,0.131,0.194,0.163,0.198,0.232,0.277,0.278,0.151,0.136,0.204,0.176,0.196,0.243,0.339,0.349,0.150,0.146,0.230,0.190,0.206,0.234,0.284,0.347,0.167,0.172,0.267,0.228,0.230,0.279,0.373,0.385,0.214,0.193,0.290,0.232,0.290,0.366,0.399,0.379,0.223,0.207,0.342,0.251,0.323,0.417,0.546,0.501,0.259,0.227,0.405,0.348,0.387,0.474,0.553,0.530,0.297,0.292,0.578,0.480,0.619,0.652,0.801,0.754,0.416,0.371,0.678,0.571,0.676,0.890,0.748,0.977,0.577,0.559,0.821,0.683,0.836,0.930,0.924,0.912,0.862,0.812,1.451,1.376,1.474,2.324,1.796,2.373,1.087,0.850,1.431,1.374,1.345,2.089,2.110,2.637,1.319,1.394,2.094,1.619,2.031,2.258,2.866,2.585,1.341,1.420,1.736,1.686,1.979,2.561,3.141,2.614,5.583,3.313,3.334,4.727,3.534,4.165,4.319,,2.535,2.247,3.305,2.952,3.444,5.804,4.760,3.273,5.156,5.861,4.078,3.269,5.597,6.710,10.386,5.828,,2.881,3.650,3.478,4.860,5.873,4.256,,0.137,0.116,0.152,0.120,0.172,0.122,0.198,0.157,0.215,0.160,0.230,0.163,0.290,0.228,0.324,0.228,0.353,0.237,0.676,0.480,0.747,0.480,0.894,0.476,2.031,1.374,2.304,1.166,2.362,1.042,5.597,2.952,6.474,2.303,7.117,2.262"), parseStat("0.075,0.068,0.121,0.101,0.104,0.126,0.150,0.150,0.085,0.090,0.137,0.118,0.119,0.145,0.183,0.179,0.105,0.093,0.145,0.120,0.139,0.168,0.195,0.193,0.103,0.107,0.150,0.131,0.143,0.174,0.259,0.243,0.106,0.107,0.175,0.141,0.149,0.183,0.224,0.226,0.121,0.127,0.194,0.162,0.164,0.204,0.257,0.264,0.152,0.138,0.199,0.168,0.202,0.241,0.279,0.283,0.156,0.142,0.213,0.179,0.207,0.267,0.342,0.374,0.154,0.153,0.240,0.192,0.212,0.248,0.292,0.357,0.175,0.181,0.278,0.233,0.237,0.295,0.378,0.396,0.221,0.202,0.303,0.236,0.300,0.395,0.415,0.408,0.227,0.203,0.352,0.275,0.330,0.454,0.546,0.471,0.270,0.236,0.439,0.382,0.410,0.523,0.619,0.584,0.311,0.343,0.600,0.507,0.660,0.724,0.866,0.835,0.437,0.404,0.719,0.581,0.706,0.978,0.807,1.026,0.606,0.575,0.829,0.719,0.879,0.991,0.986,0.917,0.862,1.019,1.451,1.372,1.661,2.359,1.877,2.173,1.091,1.471,1.542,1.407,1.545,2.216,2.113,2.637,1.391,1.584,2.133,1.549,2.083,2.205,3.223,2.585,1.306,1.583,1.736,1.702,1.987,2.645,3.141,2.614,5.583,3.313,3.686,4.727,4.142,4.165,4.319,,2.535,1.839,3.305,3.082,3.518,5.804,5.063,4.862,5.156,5.861,4.133,3.269,6.072,6.489,10.386,5.838,,2.924,4.312,3.478,4.581,5.873,4.256,,0.139,0.118,0.155,0.123,0.176,0.122,0.202,0.162,0.218,0.166,0.233,0.170,0.300,0.233,0.331,0.235,0.350,0.255,0.706,0.507,0.751,0.500,0.936,0.479,2.083,1.407,2.304,1.120,2.362,1.120,6.072,3.082,6.796,2.312,7.117,2.202")), parseStat("0.071,0.070,,,,,,,0.083,0.092,,,,,,,0.105,0.090,,,,,,,0.109,0.113,,,,,,,0.104,0.104,,,,,,,0.120,0.128,,,,,,,0.155,0.131,,,,,,,0.156,0.139,,,,,,,0.150,0.166,,,,,,,0.164,0.178,,,,,,,0.227,0.194,,,,,,,0.224,0.217,,,,,,,0.270,0.216,,,,,,,0.301,0.293,,,,,,,0.388,0.350,,,,,,,0.579,0.584,,,,,,,0.862,1.225,,,,,,,1.107,0.931,,,,,,,1.250,1.507,,,,,,,1.390,1.928,,,,,,,,2.363,,,,,,,,2.316,,,,,,,5.156,2.563,,,,,,,,2.839,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stQ1 = array.concat(array.concat(parseStat("0.651,-0.885,0.809,0.885,0.641,0.794,0.443,0.983,-0.888,0.885,-0.315,-0.044,0.479,0.969,-0.651,0.969,0.744,-0.733,0.610,0.981,-0.007,0.983,0.885,0.888,0.315,0.443,0.579,0.479,-0.885,0.885,,,0.766,0.405,0.998,-0.969,0.173,0.315,0.794,0.573,0.389,0.927,-0.744,-0.021,0.766,-0.981,-0.993,0.885,0.969,-0.641,-0.497,-0.983,-0.007,0.256,0.711,-0.885,0.576,-0.885,0.969,0.983,0.443,-0.977,,,0.888,0.983,0.443,0.885,-0.983,0.870,0.937,-0.983,0.743,-0.711,-0.888,-0.210,0.140,0.794,-0.885,0.711,0.983,-0.765,-0.140,0.443,-0.443,-0.981,0.969,0.863,0.610,0.114,-0.888,-0.981,0.983,-0.443,,,-0.765,-0.641,-0.983,0.610,-0.885,0.983,,-0.981,0.789,0.977,0.907,-0.982,0.885,-0.885,-0.885,0.983,-0.443,-0.809,-0.885,-0.911,-0.741,0.609,,,,,0.315,,,,,,,,,,,,,,,,-0.969,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-0.007,-0.044,-0.008,-0.010,-0.007,-0.055,-0.007,-0.021,-0.007,-0.067,-0.129,-0.169,-0.443,-0.210,-0.647,-0.062,0.711,-0.062,-0.741,-0.982,,-0.733,,,,,,,,,,,,,,"), parseStat("0.024,0.449,-0.938,0.411,0.309,-0.449,-0.607,-0.244,0.037,0.003,-0.024,-0.100,0.384,-0.571,-0.029,-0.119,0.020,0.011,0.407,0.938,-0.000,-0.301,-0.257,-0.301,0.009,0.173,0.899,0.292,-0.938,-0.938,,,0.033,0.198,0.845,0.738,0.252,0.449,-0.889,-0.384,0.002,0.243,-0.244,-0.292,0.911,-0.282,-0.242,-0.163,0.154,0.571,-0.154,-0.845,-0.005,0.734,-0.510,-0.086,0.099,0.045,0.607,0.500,0.531,-0.938,,,0.938,-0.845,-0.999,-0.845,-0.571,0.733,-0.571,-0.464,0.044,-0.879,0.838,-0.531,0.009,0.651,-0.270,-0.908,0.384,-0.938,-0.050,0.103,-0.384,-0.607,0.938,-0.571,0.571,0.033,-0.510,0.896,-0.798,-0.571,,,,,-0.938,0.257,-0.607,0.938,,,-0.899,0.733,0.895,-0.571,0.938,0.673,,,-0.090,-0.292,-0.921,-0.316,-0.838,0.838,,,,,,,,,,,,,,,,,,,,,-0.861,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-0.000,-0.100,-0.000,-0.002,-0.000,-0.020,-0.005,-0.292,-0.009,-0.259,-0.024,-0.344,-0.384,-0.531,-0.571,-0.098,-0.935,-0.034,-0.838,-0.571,,-0.243,,,,,,,,,,,,,,")), parseStat("0.741,-0.533,,,,,,,-0.741,0.853,,,,,,,0.741,-0.453,,,,,,,0.154,0.138,,,,,,,0.741,0.453,,,,,,,0.262,0.741,,,,,,,0.756,-0.492,,,,,,,0.453,-0.902,,,,,,,0.656,0.853,,,,,,,0.984,-0.741,,,,,,,0.984,-0.741,,,,,,,0.453,0.262,,,,,,,,,,,,,,,0.756,-0.741,,,,,,,-0.262,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stQC = array.concat(array.concat(parseStat("0.788,0.820,0.922,0.788,0.976,-0.824,0.901,-0.778,-0.824,0.636,-0.015,0.973,0.511,-0.956,-0.591,-0.347,0.620,0.976,0.788,0.695,0.820,-0.511,0.780,-0.985,0.511,0.620,-0.972,0.511,-0.956,0.850,0.956,0.633,0.780,0.641,-0.620,-0.976,0.511,-0.985,0.780,0.641,0.846,0.591,-0.620,-0.620,-0.956,-0.620,0.812,0.887,0.591,0.985,-0.936,0.985,-0.824,-0.976,-0.812,0.922,0.591,0.973,-0.788,-0.973,0.645,0.824,-0.894,0.976,0.636,0.645,0.633,0.976,0.846,0.973,-0.922,-0.695,-0.988,-0.620,-0.511,-0.039,0.788,0.788,-0.850,0.976,-0.695,-0.695,0.788,0.976,-0.780,0.633,-0.781,0.620,0.533,0.347,0.620,0.956,-0.972,0.788,,,-0.695,-0.812,0.846,0.511,-0.982,-0.976,0.695,-0.812,0.641,0.820,0.740,-0.636,-0.985,0.976,-0.982,-0.824,-0.788,-0.976,-0.922,0.976,-0.511,0.695,-0.780,-0.956,,,0.533,-0.620,-0.812,0.956,,,,,,,,,,,,,-0.620,-0.899,,,,,,,-0.846,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.820,0.973,0.670,0.956,0.620,-0.985,-0.824,-0.620,0.978,-0.956,0.846,0.864,-0.780,-0.039,-0.788,-0.511,0.645,-0.788,-0.511,-0.636,-0.633,-0.511,,,,-0.899,,,,,,,,,,"), parseStat("0.012,0.077,-0.911,0.168,0.715,-0.141,-0.170,-0.063,0.003,0.000,-0.000,0.302,0.061,-0.120,-0.001,-0.000,0.000,0.000,-0.973,0.327,0.709,-0.003,-0.258,-0.108,0.001,0.021,-0.217,0.087,-0.973,-0.743,-0.558,0.745,0.003,0.104,-0.315,0.943,0.302,-0.715,-0.745,-0.709,0.015,0.007,-0.141,-0.973,-0.973,-0.030,-0.510,-0.235,0.001,0.023,-0.404,0.795,-0.747,-0.306,-0.015,-0.338,0.114,0.071,-0.715,0.715,0.404,0.795,-0.644,-0.776,0.109,0.180,0.715,0.715,0.709,0.751,-0.318,-0.180,0.041,-0.973,-0.216,-0.087,0.180,0.745,-0.234,-0.318,0.795,-0.973,0.943,0.610,-0.709,0.841,-0.081,0.973,0.327,0.113,0.761,0.943,-0.338,0.911,,,,,0.943,0.106,-0.943,-0.943,,,0.235,0.302,0.510,-0.108,-0.526,0.715,0.943,-0.380,-0.911,0.795,-0.748,0.973,-0.176,0.644,-0.180,-0.715,,,0.318,-0.252,-0.820,-0.977,,,,,,,,,,,,,-0.349,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.709,0.302,0.715,0.715,0.452,-0.943,-0.747,-0.973,0.943,0.747,0.940,0.510,-0.709,-0.087,-0.715,-0.338,0.811,-0.751,-0.176,-0.108,-0.366,-0.021,,,,,,,,,,,,,,")), parseStat("0.766,-0.980,,,,,,,-0.785,0.470,,,,,,,0.351,-0.785,,,,,,,0.351,0.351,,,,,,,0.785,0.591,,,,,,,0.495,0.351,,,,,,,0.351,-0.909,,,,,,,0.351,0.766,,,,,,,0.351,0.568,,,,,,,-0.772,-0.653,,,,,,,-0.351,-0.785,,,,,,,0.351,0.243,,,,,,,,,,,,,,,0.906,0.800,,,,,,,-0.638,-0.766,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stPF = array.concat(array.concat(parseStat("47.4,42.5,52.5,30.6,33.1,49.3,38.5,38.7,42.1,48.2,50.4,33.2,30.7,51.6,36.8,39.9,52.0,38.2,55.0,29.1,35.9,46.9,41.7,34.1,47.4,41.8,50.3,31.8,35.3,46.4,38.8,33.7,44.5,46.0,51.2,30.6,33.7,46.9,40.3,36.4,41.8,47.8,51.0,32.9,31.6,50.7,35.5,41.4,52.1,38.0,55.9,28.0,36.1,46.0,42.4,34.2,47.3,41.5,51.8,31.6,35.6,47.2,37.4,37.4,51.9,38.2,53.5,29.8,34.6,47.1,41.1,39.5,42.4,47.6,51.0,31.8,31.2,50.9,40.6,41.0,53.1,35.8,55.9,28.4,36.2,46.3,44.6,34.7,47.8,39.9,50.5,33.3,35.7,44.6,40.5,35.5,49.2,40.5,58.2,31.4,37.9,46.4,45.6,46.0,41.7,40.1,53.4,28.2,33.0,45.0,38.2,45.3,49.4,33.5,53.1,30.1,31.8,45.3,50.7,35.6,42.2,37.8,55.3,25.8,34.7,42.7,44.6,36.4,60.0,30.0,66.7,25.3,34.8,52.2,39.5,48.8,59.0,34.4,59.3,30.8,34.2,50.3,41.5,43.9,55.1,39.1,69.5,24.0,43.7,43.1,35.2,38.9,61.8,35.3,57.4,26.5,42.9,39.0,33.3,33.3,33.3,66.7,58.3,41.7,33.3,44.4,100.0,,38.5,38.5,55.2,34.5,52.8,41.7,53.3,33.3,75.0,25.0,74.3,20.0,42.9,48.6,27.3,72.7,,100.0,75.0,18.8,40.0,50.0,100.0,,35.9,33.2,36.5,33.9,36.9,34.4,36.1,32.9,35.2,33.7,35.7,32.3,36.2,31.8,37.7,31.5,37.3,29.9,31.8,28.2,30.8,27.6,33.3,27.6,43.7,30.8,46.8,27.4,48.4,30.3,42.9,34.5,53.8,34.8,50.0,25.0"), parseStat(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,")), parseStat("59.4,56.5,,,,,,,63.2,60.3,,,,,,,63.0,61.0,,,,,,,65.0,61.8,,,,,,,58.7,58.9,,,,,,,65.4,61.5,,,,,,,64.2,61.6,,,,,,,62.8,60.5,,,,,,,68.6,55.8,,,,,,,63.9,60.2,,,,,,,63.3,57.5,,,,,,,63.2,57.0,,,,,,,62.7,55.5,,,,,,,61.7,52.1,,,,,,,60.9,52.8,,,,,,,57.7,51.8,,,,,,,66.7,25.0,,,,,,,69.0,46.9,,,,,,,66.7,71.4,,,,,,,72.0,55.6,,,,,,,,50.0,,,,,,,,36.4,,,,,,,85.7,100.0,,,,,,,,100.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stPO = array.concat(array.concat(parseStat("42.5,47.4,30.6,52.5,49.3,33.1,38.7,38.5,48.2,42.1,33.2,50.4,51.6,30.7,39.9,36.8,38.2,52.0,29.1,55.0,46.9,35.9,34.1,41.7,41.8,47.4,31.8,50.3,46.4,35.3,33.7,38.8,46.0,44.5,30.6,51.2,46.9,33.7,36.4,40.3,47.8,41.8,32.9,51.0,50.7,31.6,41.4,35.5,38.0,52.1,28.0,55.9,46.0,36.1,34.2,42.4,41.5,47.3,31.6,51.8,47.2,35.6,37.4,37.4,38.2,51.9,29.8,53.5,47.1,34.6,39.5,41.1,47.6,42.4,31.8,51.0,50.9,31.2,41.0,40.6,35.8,53.1,28.4,55.9,46.3,36.2,34.7,44.6,39.9,47.8,33.3,50.5,44.6,35.7,35.5,40.5,40.5,49.2,31.4,58.2,46.4,37.9,46.0,45.6,40.1,41.7,28.2,53.4,45.0,33.0,45.3,38.2,33.5,49.4,30.1,53.1,45.3,31.8,35.6,50.7,37.8,42.2,25.8,55.3,42.7,34.7,36.4,44.6,30.0,60.0,25.3,66.7,52.2,34.8,48.8,39.5,34.4,59.0,30.8,59.3,50.3,34.2,43.9,41.5,39.1,55.1,24.0,69.5,43.1,43.7,38.9,35.2,35.3,61.8,26.5,57.4,39.0,42.9,33.3,33.3,66.7,33.3,41.7,58.3,44.4,33.3,0.0,,38.5,38.5,34.5,55.2,41.7,52.8,33.3,53.3,25.0,75.0,20.0,74.3,48.6,42.9,72.7,27.3,,0.0,18.8,75.0,50.0,40.0,0.0,,46.9,50.4,46.2,49.8,45.7,48.9,46.0,51.0,47.2,50.1,46.9,50.6,46.3,51.0,44.6,50.1,42.8,52.1,45.3,53.4,44.5,52.7,42.8,55.2,43.1,59.3,42.9,64.2,41.9,64.0,48.6,55.2,46.2,54.3,50.0,58.3"), parseStat(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,")), parseStat("29.7,34.1,,,,,,,28.4,29.2,,,,,,,26.6,30.3,,,,,,,24.9,26.5,,,,,,,32.2,31.2,,,,,,,25.3,27.4,,,,,,,25.5,29.2,,,,,,,26.4,27.9,,,,,,,21.8,33.9,,,,,,,27.3,29.0,,,,,,,25.0,32.7,,,,,,,23.5,31.7,,,,,,,26.1,35.2,,,,,,,22.5,28.1,,,,,,,22.2,29.7,,,,,,,25.8,24.1,,,,,,,33.3,50.0,,,,,,,20.7,50.0,,,,,,,25.0,28.6,,,,,,,28.0,33.3,,,,,,,,50.0,,,,,,,,45.5,,,,,,,14.3,0.0,,,,,,,,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stPN = array.concat(array.concat(parseStat("10.1,10.1,16.9,16.9,17.7,17.7,22.8,22.8,9.7,9.7,16.4,16.4,17.7,17.7,23.3,23.3,9.8,9.8,15.9,15.9,17.3,17.3,24.2,24.2,10.8,10.8,17.9,17.9,18.3,18.3,27.4,27.4,9.5,9.5,18.2,18.2,19.4,19.4,23.3,23.3,10.4,10.4,16.0,16.0,17.6,17.6,23.1,23.1,9.9,9.9,16.1,16.1,17.9,17.9,23.4,23.4,11.2,11.2,16.6,16.6,17.1,17.1,25.2,25.2,9.9,9.9,16.7,16.7,18.3,18.3,19.4,19.4,10.0,10.0,17.2,17.2,17.9,17.9,18.4,18.4,11.1,11.1,15.8,15.8,17.5,17.5,20.7,20.7,12.3,12.3,16.2,16.2,19.7,19.7,24.0,24.0,10.3,10.3,10.5,10.5,15.8,15.8,8.4,8.4,18.2,18.2,18.4,18.4,22.0,22.0,16.4,16.4,17.1,17.1,16.9,16.9,22.9,22.9,13.7,13.7,20.0,20.0,18.9,18.9,22.5,22.5,19.0,19.0,10.0,10.0,8.0,8.0,13.0,13.0,11.6,11.6,6.6,6.6,9.9,9.9,15.5,15.5,14.6,14.6,5.8,5.8,6.5,6.5,13.2,13.2,25.9,25.9,2.9,2.9,16.2,16.2,18.2,18.2,33.3,33.3,-0.0,-0.0,0.0,0.0,22.2,22.2,0.0,,23.1,23.1,10.3,10.3,5.6,5.6,13.3,13.3,0.0,0.0,5.7,5.7,8.6,8.6,-0.0,-0.0,,0.0,6.2,6.2,10.0,10.0,0.0,,17.3,16.4,17.3,16.3,17.4,16.7,17.9,16.0,17.7,16.2,17.4,17.1,17.5,17.2,17.7,18.4,19.9,18.1,22.9,18.4,24.8,19.6,23.9,17.3,13.2,9.9,10.4,8.4,9.7,5.6,8.6,10.3,0.0,10.9,0.0,16.7"), parseStat(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,")), parseStat("10.8,9.4,,,,,,,8.4,10.5,,,,,,,10.4,8.7,,,,,,,10.0,11.7,,,,,,,9.2,9.9,,,,,,,9.3,11.0,,,,,,,10.3,9.2,,,,,,,10.9,11.6,,,,,,,9.6,10.2,,,,,,,8.8,10.8,,,,,,,11.8,9.8,,,,,,,13.2,11.3,,,,,,,11.2,9.4,,,,,,,15.9,19.8,,,,,,,16.9,17.5,,,,,,,16.5,24.1,,,,,,,-0.0,25.0,,,,,,,10.3,3.1,,,,,,,8.3,-0.0,,,,,,,0.0,11.1,,,,,,,,0.0,,,,,,,,18.2,,,,,,,0.0,0.0,,,,,,,,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"))
var array<float> stBP = parseStat("50.5,51.7,51.6,51.7,52.2,51.7,52.7,52.3,51.1,51.4,57.0,42.6,60.4,61.5,62.1,62.0,63.6,63.3,67.3,67.5,64.9,60.5,64.9,53.3,50.7,51.7,51.3,52.0,51.6,51.2,53.5,52.1,50.0,48.3,54.8,43.1")
var array<float> stBC = parseStat("51.0,48.5,51.9,47.6,52.5,47.1,55.3,48.1,56.1,46.3,62.6,47.3,56.7,53.9,57.8,53.4,58.9,53.6,64.0,56.4,64.5,52.1,67.3,57.1,50.9,48.0,51.5,47.3,52.3,47.0,56.3,48.0,56.7,45.8,60.5,48.8")
// type code (1 / 2 / -2 / 3) -> 0 inside, 1 = 2U, 2 = 2D, 3 outside
tIdx(int c) => c == 3 ? 3 : c == 2 ? 1 : c == -2 ? 2 : 0
// cell index for a row: kP = previous-bar code, kS = setup-bar code, blk = population block
statLookup(int tfI, string nmx, int sdx, int kP, int kS, int blk) =>
int r = -1
if nmx == "PMG" and sdx != 0
r := blk * 228 + 192 + (tfI * 3 + (pmgN - 2)) * 2 + (sdx == 1 ? 0 : 1)
else if nmx != "" and sdx != 0
r := blk * 228 + ((tfI * 4 + tIdx(kP)) * 4 + tIdx(kS)) * 2 + (sdx == 1 ? 0 : 1)
r
sget(array<float> a, int idx) => idx >= 0 ? array.get(a, idx) : na
fmtS(float x, string f) => na(x) ? "n/a" : str.tostring(x, f)
pmgTxt(string nmx) => nmx == "PMG" ? "PMG≥" + str.tostring(pmgN) : nmx
buildTip(string tfl, string nmx, int sdx, int blk, int kP, int kS, int idx, int bIdx, string tag) =>
string tip = "No stats for this pattern"
float vN = sget(stN, idx)
float vN1 = sget(stN1, idx)
float vP = sget(stP1, idx)
float vC = sget(stCB, idx)
float vE = sget(stEx, idx)
float vS = sget(stSt, idx)
float vR = sget(stRk, idx)
float vQ = sget(stQ1, idx)
float vQc = sget(stQC, idx)
float vF = sget(stPF, idx)
float vO = sget(stPO, idx)
float vZ = sget(stPN, idx)
float bP = sdx != 0 ? array.get(stBP, bIdx) : na
float bC = sdx != 0 ? array.get(stBC, bIdx) : na
if not na(vN)
bool sig = not na(vQ) and math.abs(vQ) < 0.10
bool sigC = not na(vQc) and math.abs(vQc) < 0.10
bool thin = na(vN1) or vN1 < 100
string dtx = sdx == 1 ? "long" : "short"
string cell = nmx == "PMG" ? "PMG: run of " + str.tostring(pmgN) + "+ same-direction bars, then trade the reversal" : "Study cell: " + typeStr(kP) + " -> " + typeStr(kS) + " (previous -> setup bar), " + dtx + " trigger"
string pop = blk == 1 ? "Population: trades whose trigger bar was single-sided (2U/2D) = TRIGGERED" : blk == 2 ? "Population: inside setup bar that closed " + (sdx == 1 ? "up/flat" : "down") + ", this side broke first" : "Population: every trade where this side of the setup bar broke first"
tip := tfl + " " + pmgTxt(nmx) + " " + dtx + tag + "\n" + cell + "\n" + pop + "\n"
tip += "NQ study 2019-06-02 to 2025-03-14 - descriptive history, not a forecast\n"
if blk != 1
tip += "Side breaks first: " + fmtS(vF, "0.0") + "% other side first: " + fmtS(vO, "0.0") + "% neither: " + fmtS(vZ, "0.0") + "%\n"
tip += "Trades: " + fmtS(vN, "#") + " resolved (+1R or stop): " + fmtS(vN1, "#") + "\n"
if blk != 1
tip += "+1R first (of resolved): " + fmtS(vP, "0.0") + "% baseline for this population " + fmtS(bP, "0.0") + "%\n"
else
tip += "+1R / stop outcome not shown: the trigger bar has already played, and history measured from entry overstates what is left\n"
if blk == 1
tip += "Trigger bar already closed beyond/inside the level - close-beyond is known, not shown\n"
else
tip += "Trigger bar closed beyond trigger: " + fmtS(vC, "0.0") + "% time-of-day-matched expectation " + fmtS(vE, "0.0") + "% (baseline " + fmtS(bC, "0.0") + "%)\n"
tip += "Stop touched within 3 bars: " + fmtS(vS, "0.0") + "%\n"
tip += "Median stop distance: " + fmtS(vR, "0.00") + "% of price\n"
if blk != 1
tip += "q (+1R vs baseline): " + fmtS(math.abs(vQ), "0.000") + (sig ? (vQ > 0 ? " ABOVE baseline" : " BELOW baseline") : " - not distinguishable") + "\n"
tip += "q (close-beyond vs matched): " + fmtS(math.abs(vQc), "0.000") + (sigC ? (vQc > 0 ? " ABOVE expectation" : " BELOW expectation") : " - not distinguishable") + "\n"
tip += "Events overlap (consecutive bars), so q-values are optimistic."
if thin
tip += "\nThin sample (<100 resolved): treat as noise"
if blk == 1
tip += "\nShown for TRIGGERED: how often this setup has occurred (n) and its median stop distance (Risk%)"
tip
int chartMins = tfMins(timeframe.period)
// FTFC verdict over valid rows only
int nBull = 0, nBear = 0, nValid = 0
for i = 0 to 5
if tfMins(array.get(tfCodes, i)) >= chartMins
nValid += 1
d = array.get(dirs, i)
if d == 1
nBull += 1
else if d == -1
nBear += 1
int ftfcState = nValid > 0 and nBull == nValid ? 1 : nValid > 0 and nBear == nValid ? -1 : 0
// continuity lean: the aligned direction, or the majority when mixed
int leanDir = ftfcState != 0 ? ftfcState : (nBull > nBear ? 1 : nBull < nBear ? -1 : 0)
// ---------------------------------------------------------------------
// DASHBOARD
// ---------------------------------------------------------------------
txtSize(string s) =>
switch s
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
=> size.small
if showDash and barstate.islast
string dFont = dashMono ? font.family_monospace : font.family_default
dSz = txtSize(dashSize)
bool statsOn = showStats and (statsAnySym or syminfo.root == "NQ" or syminfo.root == "MNQ")
int nStat = statsOn ? 5 : 0
int ncols = 6 + nStat + (showAlign ? 1 : 0)
int lastc = ncols - 1
int alignCol = 6 + nStat
var table t = table.new(tablePos(dashV, dashH), ncols, 8, border_color = dashBorder, border_width = dashBorderW, frame_color = dashFrame, frame_width = dashFrameW)
// row 0 — FTFC banner (coloured when aligned)
color bannerBg = ftfcState == 1 ? dashUp : ftfcState == -1 ? dashDown : dashHeadBg
color bannerTx = ftfcState != 0 ? dashOnColor : dashText
string verdict = ftfcState == 1 ? "ALIGNED ▲" : ftfcState == -1 ? "ALIGNED ▼" : "MIXED"
table.cell(t, 0, 0, "FTFC", text_color = bannerTx, bgcolor = bannerBg, text_size = dSz, text_halign = text.align_left, text_font_family = dFont)
table.cell(t, 1, 0, verdict, text_color = bannerTx, bgcolor = bannerBg, text_size = dSz, text_halign = text.align_left, text_font_family = dFont)
table.cell(t, 2, 0, str.tostring(nBull) + "▲ " + str.tostring(nBear) + "▼", text_color = bannerTx, bgcolor = bannerBg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
for c = 3 to lastc - 1
table.cell(t, c, 0, "", bgcolor = bannerBg)
table.cell(t, lastc, 0, "Strat", text_color = bannerTx, bgcolor = bannerBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont)
// row 1 — headers
table.cell(t, 0, 1, "TF", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_left, text_font_family = dFont)
table.cell(t, 1, 1, "Dir", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
table.cell(t, 2, 1, "Seq", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
table.cell(t, 3, 1, "Setup", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_left, text_font_family = dFont)
table.cell(t, 4, 1, "Trigger", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont)
table.cell(t, 5, 1, "Status", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
if statsOn
table.cell(t, 6, 1, "1st%", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont)
table.cell(t, 7, 1, "n", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont)
table.cell(t, 8, 1, "+1R%", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont)
table.cell(t, 9, 1, "CB%", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont)
table.cell(t, 10, 1, "Risk%", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont)
if showAlign
table.cell(t, alignCol, 1, "±FTFC", text_color = dashMuted, bgcolor = dashHeadBg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
// rows 2..7 — timeframes
for i = 0 to 5
int row = i + 2
string code = array.get(tfCodes, i)
bool valid = tfMins(code) >= chartMins
int dir = array.get(dirs, i)
string seq = array.get(seqs, i)
string nm = array.get(names, i)
int sd = array.get(sdirs, i)
float tg = array.get(trigs, i)
int st = array.get(stats, i)
table.cell(t, 0, row, tfLabel(code), text_color = dashText, bgcolor = dashBg, text_size = dSz, text_halign = text.align_left, text_font_family = dFont)
if not valid
for c = 1 to lastc
table.cell(t, c, row, "—", text_color = dashMuted, bgcolor = dashBg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
continue
// Dir — coloured cell
string darr = dir == 1 ? "▲" : dir == -1 ? "▼" : "•"
color dbg = dir == 1 ? dashUp : dir == -1 ? dashDown : dashBg
color dtx = dir == 0 ? dashMuted : dashOnColor
table.cell(t, 1, row, darr, text_color = dtx, bgcolor = dbg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
// Seq
table.cell(t, 2, row, seq, text_color = dashText, bgcolor = dashBg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
// Setup bar behind this row and the in-play setup its closed bar also creates (shown next to a TRIGGERED pattern)
string pnm = array.get(pns, i)
int pdr = array.get(pds, i)
string shTip = ""
if statsOn
int k1v = array.get(k1s, i)
int k2v = array.get(k2s, i)
int k3v = array.get(k3s, i)
int blk = st == 2 ? 1 : (k1v == 1 ? 2 : 0)
int kS = st == 2 ? k2v : k1v
int kP = st == 2 ? k3v : k2v
int sIdx = statLookup(i, nm, sd, kP, kS, blk)
int bIdx = blk * 12 + i * 2 + (sd == 1 ? 0 : 1)
float vN = sget(stN, sIdx)
float vN1 = sget(stN1, sIdx)
float vP = sget(stP1, sIdx)
float vC = sget(stCB, sIdx)
float vR = sget(stRk, sIdx)
float vQ = sget(stQ1, sIdx)
float vQc = sget(stQC, sIdx)
float vF = sget(stPF, sIdx)
bool okS = not na(vN)
bool thin = okS and (na(vN1) or vN1 < 100)
bool sig = okS and not na(vQ) and math.abs(vQ) < 0.10
bool sigC = okS and not na(vQc) and math.abs(vQc) < 0.10
string mk = not sig ? "" : vQ > 0 ? "↑" : "↓"
string mkC = not sigC ? "" : vQc > 0 ? "↑" : "↓"
color sTx = okS and not thin ? dashText : dashMuted
string tip = buildTip(tfLabel(code), nm, sd, blk, kP, kS, sIdx, bIdx, st == 2 ? " [TRIGGERED]" : " [in play]")
if st == 2 and pnm != ""
int blk2 = k1v == 1 ? 2 : 0
int sIdx2 = statLookup(i, pnm, pdr, k2v, k1v, blk2)
int bIdx2 = blk2 * 12 + i * 2 + (pdr == 1 ? 0 : 1)
shTip := buildTip(tfLabel(code), pnm, pdr, blk2, k2v, k1v, sIdx2, bIdx2, " [in play next - stats shown for this, not the triggered row]")
table.cell(t, 6, row, okS and blk != 1 and not na(vF) ? fmtS(vF, "0") : "—", text_color = sTx, bgcolor = dashBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont, tooltip = tip)
table.cell(t, 7, row, okS ? str.tostring(vN, "#") : "—", text_color = sTx, bgcolor = dashBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont, tooltip = tip)
table.cell(t, 8, row, okS and blk != 1 and not na(vP) ? fmtS(vP, "0.0") + mk : "—", text_color = sTx, bgcolor = dashBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont, tooltip = tip)
table.cell(t, 9, row, okS and blk != 1 and not na(vC) ? fmtS(vC, "0.0") + mkC : "—", text_color = sTx, bgcolor = dashBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont, tooltip = tip)
table.cell(t, 10, row, okS and not na(vR) ? fmtS(vR, "0.00") : "—", text_color = sTx, bgcolor = dashBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont, tooltip = tip)
// Setup
string sarr = sd == 1 ? " ▲" : sd == -1 ? " ▼" : ""
string stxt = nm == "" ? "—" : pmgTxt(nm) + sarr
if st == 2 and pnm != ""
stxt += "\n▸ " + pmgTxt(pnm) + (pdr == 1 ? " ▲" : " ▼")
table.cell(t, 3, row, stxt, text_color = nm == "" ? dashMuted : dashText, bgcolor = dashBg, text_size = dSz, text_halign = text.align_left, text_font_family = dFont, tooltip = shTip)
// Trigger
string ttxt = na(tg) ? "—" : str.tostring(tg, format.mintick)
table.cell(t, 4, row, ttxt, text_color = na(tg) ? dashMuted : dashText, bgcolor = dashBg, text_size = dSz, text_halign = text.align_right, text_font_family = dFont)
// Status — TRIGGERED filled by direction, in-play amber
string sttxt = st == 2 ? "TRIGGERED" : st == 1 ? "in play" : "—"
color stbg = st == 2 ? (sd == 1 ? dashUp : dashDown) : st == 1 ? dashInPlay : dashBg
color sttc = st == 0 ? dashMuted : dashOnColor
table.cell(t, 5, row, sttxt, text_color = sttc, bgcolor = stbg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
// ±FTFC — does this setup point WITH the overall continuity?
if showAlign
bool hasAlign = nm != "" and sd != 0 and leanDir != 0
bool withCont = hasAlign and sd == leanDir
string atxt = not hasAlign ? "—" : withCont ? "✓" : "✗"
color atx = not hasAlign ? dashMuted : withCont ? dashUp : dashDown
table.cell(t, alignCol, row, atxt, text_color = atx, bgcolor = dashBg, text_size = dSz, text_halign = text.align_center, text_font_family = dFont)
// ---------------------------------------------------------------------
// HTF OVERLAY — proper candlesticks, floated to the RIGHT of live price
// ---------------------------------------------------------------------
type HtfC
float o
float h
float l
float c
int code
box body
line wickUp
line wickDn
label lbl
label sig
selCode = switch overlaySel
"15m" => "15"
"30m" => "30"
"1h" => "60"
"4h" => "240"
"1D" => "1D"
"1W" => "1W"
=> "None"
string overlayTF = selCode == "None" ? timeframe.period : selCode
bool overlayValid = selCode != "None" and tfMins(selCode) >= chartMins
var array<HtfC> hcs = array.new<HtfC>()
// Aggregate the selected HTF's candles directly from chart bars.
// overlayValid guarantees overlayTF >= chart TF, so each HTF candle spans
// one or more chart bars. Index 0 is always the developing candle.
if overlayValid
bool fresh = timeframe.change(overlayTF)
if fresh or hcs.size() == 0
hcs.unshift(HtfC.new(open, high, low, close, 0, na, na, na, na, na))
while hcs.size() > overlayCount + 2
HtfC ev = hcs.pop()
if not na(ev.body)
box.delete(ev.body)
if not na(ev.wickUp)
line.delete(ev.wickUp)
if not na(ev.wickDn)
line.delete(ev.wickDn)
if not na(ev.lbl)
label.delete(ev.lbl)
if not na(ev.sig)
label.delete(ev.sig)
else
HtfC cur = hcs.first()
cur.h := math.max(cur.h, high)
cur.l := math.min(cur.l, low)
cur.c := close
// track the chart bar where each overlay-TF candle began (to anchor levels)
var int htfPS0 = na
var int htfPS1 = na
var array<line> dividers = array.new<line>()
if overlayValid and timeframe.change(overlayTF)
htfPS1 := htfPS0
htfPS0 := bar_index
if showDividers
dividers.unshift(line.new(bar_index, low, bar_index, high, xloc = xloc.bar_index, extend = extend.both, color = divCol, style = lineStyle(divStyle), width = divWidth))
while dividers.size() > divCount
line.delete(dividers.shift())
// Draw the floating cluster (only on the last / realtime bar).
var label ovTfLbl = na
if overlayValid and (barstate.islast or barstate.isrealtime)
int n = hcs.size()
int drawN = math.min(n, overlayCount)
// classify every candle vs its older neighbour
for i = 0 to n - 1
HtfC c = hcs.get(i)
if i + 1 < n
HtfC older = hcs.get(i + 1)
c.code := stratCode(c.h, c.l, older.h, older.l)
else
c.code := 0
// work out a vertical scale so the cluster stays a readable height
float clMax = na
float clMin = na
for i = 0 to drawN - 1
HtfC c = hcs.get(i)
clMax := na(clMax) ? c.h : math.max(clMax, c.h)
clMin := na(clMin) ? c.l : math.min(clMin, c.l)
float clMid = (clMax + clMin) / 2.0
float clRange = clMax - clMin
float kScale = ovScale
if ovFit and clRange > 0 and not na(chartAtr)
kScale := math.min(1.0, chartAtr * ovFitMult / clRange)
// label naming the overlay timeframe, above the cluster
int cxMid = bar_index + ovOffset + int(ovSpacing * (drawN - 1) / 2.0) + 1
float yTop = scaleY(clMax, clMid, kScale) + (na(chartAtr) ? 0.0 : chartAtr * kScale * 1.2)
if na(ovTfLbl)
ovTfLbl := label.new(cxMid, yTop, "", xloc = xloc.bar_index, style = label.style_none, size = size.normal, text_font_family = font.family_monospace)
label.set_xy(ovTfLbl, cxMid, yTop)
label.set_text(ovTfLbl, tfLabel(selCode) + " HTF")
label.set_textcolor(ovTfLbl, chart.fg_color)
// render newest at the right edge of the cluster
for i = 0 to drawN - 1
HtfC c = hcs.get(i)
int leftBar = bar_index + ovOffset + ovSpacing * (drawN - 1 - i)
int midX = leftBar + 1
bool bull = c.c >= c.o
float sh = scaleY(c.h, clMid, kScale)
float sl = scaleY(c.l, clMid, kScale)
float so = scaleY(c.o, clMid, kScale)
float scl = scaleY(c.c, clMid, kScale)
float top = math.max(so, scl)
float bot = math.min(so, scl)
if na(c.body)
c.body := box.new(leftBar, top, leftBar + 2, bot, xloc = xloc.bar_index)
c.wickUp := line.new(midX, sh, midX, top, xloc = xloc.bar_index)
c.wickDn := line.new(midX, bot, midX, sl, xloc = xloc.bar_index)
c.lbl := label.new(midX, sh, "", xloc = xloc.bar_index, style = label.style_none, color = na, textcolor = ovLblTx, size = size.small, text_font_family = font.family_monospace)
c.sig := label.new(midX, sl, "", xloc = xloc.bar_index, style = label.style_none, color = na, textcolor = ovSetBull, size = size.small, text_font_family = font.family_monospace)
box.set_left(c.body, leftBar)
box.set_right(c.body, leftBar + 2)
box.set_top(c.body, top)
box.set_bottom(c.body, bot)
box.set_bgcolor(c.body, bull ? ovBull : ovBear)
box.set_border_color(c.body, ovBorder)
line.set_xy1(c.wickUp, midX, sh)
line.set_xy2(c.wickUp, midX, top)
line.set_color(c.wickUp, ovWick)
line.set_xy1(c.wickDn, midX, bot)
line.set_xy2(c.wickDn, midX, sl)
line.set_color(c.wickDn, ovWick)
// small vertical gap so style_none text clears the wick tips
float offY = na(chartAtr) ? 0.0 : chartAtr * kScale * 0.5
// Strat number label (above the candle)
if showOvLabels and c.code != 0
label.set_xy(c.lbl, midX, sh + offY)
label.set_text(c.lbl, typeStr(c.code))
label.set_textcolor(c.lbl, ovLblTx)
else
label.set_text(c.lbl, "")
// Setup label (below the candle) — this candle as the pattern's trigger
string snm = ""
int sdr = 0
if showOvSetups
int k2 = i + 1 < n ? hcs.get(i + 1).code : 0
int k3 = i + 2 < n ? hcs.get(i + 2).code : 0
int k4 = i + 3 < n ? hcs.get(i + 3).code : 0
int k5 = i + 4 < n ? hcs.get(i + 4).code : 0
[nm2, dr2] = completedSetup(c.code, k2, k3, k4, k5)
snm := nm2
sdr := dr2
if snm != ""
label.set_xy(c.sig, midX, sl - offY)
label.set_text(c.sig, snm + (sdr == 1 ? " ▲" : " ▼"))
label.set_textcolor(c.sig, sdr == 1 ? ovSetBull : ovSetBear)
else
label.set_text(c.sig, "")
// ---------------------------------------------------------------------
// ON-CHART ENTRY / STOP LEVELS (for the same TF as the HTF overlay candles)
// Entry = trigger level in the setup's direction; stop = opposite extreme.
// ---------------------------------------------------------------------
var line lnHi = na
var line lnLo = na
var label lbHi = na
var label lbLo = na
if showLevels
float hiLvl = na
float loLvl = na
string lvNm = ""
string lvTf = selCode
int lvSd = 0
float lvTrig = na
int li = tfStatIdx(selCode)
if overlayValid and li >= 0
hiLvl := array.get(hi1s, li)
loLvl := array.get(lo1s, li)
lvNm := array.get(names, li)
lvSd := array.get(sdirs, li)
lvTrig := array.get(trigs, li)
if barstate.islast and lvNm != "" and lvSd != 0 and not na(lvTrig)
bool lng = lvSd > 0
float entry = lvTrig + (lng ? syminfo.mintick : -syminfo.mintick) // study: entry = setup-bar level +/- 1 tick
float stopP = lng ? loLvl - syminfo.mintick : hiLvl + syminfo.mintick // study: stop = far side of the SETUP bar -/+ 1 tick
int xL = not na(htfPS1) ? htfPS1 : bar_index - 1
int xR1 = bar_index + lvExtend
color entryCol = lng ? lvUpCol : lvDnCol
color stopCol = color.new(color.gray, 0)
if na(lnHi)
lnHi := line.new(xL, entry, xR1, entry, xloc = xloc.bar_index)
lnLo := line.new(xL, stopP, xR1, stopP, xloc = xloc.bar_index, style = line.style_dashed)
lbHi := label.new(xR1, entry, "", xloc = xloc.bar_index, style = label.style_none, size = size.small, text_font_family = font.family_monospace)
lbLo := label.new(xR1, stopP, "", xloc = xloc.bar_index, style = label.style_none, size = size.small, text_font_family = font.family_monospace)
line.set_xy1(lnHi, xL, entry)
line.set_xy2(lnHi, xR1, entry)
line.set_color(lnHi, entryCol)
line.set_width(lnHi, lvWidth)
line.set_xy1(lnLo, xL, stopP)
line.set_xy2(lnLo, xR1, stopP)
line.set_color(lnLo, stopCol)
line.set_width(lnLo, lvWidth)
label.set_xy(lbHi, xR1, entry)
label.set_text(lbHi, tfLabel(lvTf) + (lng ? " ▲ long " : " ▼ short ") + str.tostring(entry, format.mintick) + " " + lvNm)
label.set_textcolor(lbHi, entryCol)
label.set_xy(lbLo, xR1, stopP)
label.set_text(lbLo, "stop " + str.tostring(stopP, format.mintick))
label.set_textcolor(lbLo, stopCol)
else
if not na(lnHi)
line.delete(lnHi)
line.delete(lnLo)
label.delete(lbHi)
label.delete(lbLo)
lnHi := na
lnLo := na
lbHi := na
lbLo := na
// ---------------------------------------------------------------------
// ALERTS
// ---------------------------------------------------------------------
// fire once per NEW trigger (state change), not on every chart bar while the HTF state persists
newTrig(int s, float g, string n) => s == 2 and (nz(s[1]) != 2 or nz(g) != nz(g[1]) or n != n[1])
bool nt15 = newTrig(u15, g15, n15)
bool nt30 = newTrig(u30, g30, n30)
bool nt60 = newTrig(u60, g60, n60)
bool nt24 = newTrig(u24, g24, n24)
bool ntD = newTrig(uD, gD, nD)
bool ntW = newTrig(uW, gW, nW)
alertcondition(nt15 or nt30 or nt60 or nt24 or ntD or ntW, "Any HTF setup triggered", "A new Strat setup triggered on one of the HTF timeframes")
alertcondition(ftfcState != 0, "Full timeframe continuity", "All HTF timeframes are aligned")