Signal_Data_2021_09_09__2021_11_18
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ubiquity

//@version=5

// @description Functions to support my timing signals system
library("Signal_Data_2021_09_09__2021_11_18", overlay=true)

// import ubiquity/DebugConsole/1 as dbug

// @function parses a string into smaller strings and stores them in an array
// @param _arr is the array to store the shorter strings
// @param str is the string to parse
// @param sep is the sentinal value used to separate the string into smaller strings
// @returns nothing. the parsed strings are all in the array
stringArrayAppend(_arr, str, sep) =>
    var string[] str_a = str.split(str, sep)
    for i = 0 to array.size(str_a) - 1 by 1
        if array.size(str_a) > 0
            ts = array.shift(str_a)
            array.push(_arr, ts)

// ======================================================================
// All the data below is from an external preprocessing system
// ======================================================================

// pine script limits string length to 4096.
// So to bypass this limitation the external preprocessor chops up long strings of data into multiple strings
// Then the stringArrayAppend function parses them all into a single array.
// You can see this with strings H03, H04, H06 and H08 as they are used multiple times.
var H01_str1 = '1624428394,1,250.7,12,250.7;1624692925,1,296.07,9,296.07;1624793000,1,312.57,6,312.57;1624916000,1,332.08,5,332.08;1625055872,1,353.19,8,353.19;1625192288,1,12.85,10,12.85;1625416854,1,43.93,7,43.93;1625611188,1,70.48,11,70.48;1625717999,1,85.23,2,85.23;1625879796,1,108.03,0,108.03;1626088441,1,138.49,3,138.49;1626092947,1,139.17,4,139.17;1626183160,3,139.82,4,139.82;1626787310,1,249.8,12,249.8;1627058055,1,295.42,9,295.42;1627151078,1,310.81,6,310.81;1627271757,1,330.25,5,330.25;1627418836,1,352.93,8,352.93;1627554419,1,12.85,10,12.85;1627781658,1,44.64,7,44.64;1627826849,2,129.54,0,129.54;1627959127,1,68.91,11,68.91;1628430607,1,136.24,0,136.24;1628487915,1,144.94,2,144.94;1628566929,1,157.11,4,157.11;1628676926,1,174.36,3,174.36;1629129863,1,247.59,12,247.59;1629343661,2,162.8,4,162.8;1629417555,1,294.82,9,294.82;1629503728,1,308.83,6,308.83;1629616710,1,326.93,5,326.93;1629780597,1,352.35,8,352.35;1629914372,1,12.24,10,12.24;1630144290,1,44.76,7,44.76;1630300411,1,66.16,11,66.16;1630975905,1,164.64,0,164.64;1631042611,1,175.36,4,175.36;1631149243,1,192.75,2,192.75;1631249270,1,209.24,3,209.24;1631464503,1,244.74,12,244.74;1631770780,1,294.41,9,294.41;1631852032,1,307.35,6,307.35;1631956459,1,323.77,5,323.77;1632137960,1,351.62,8,351.62;1632269780,1,11.17,10,11.17;1632502566,1,44.29,7,44.29;1632641551,1,63.42,11,63.42;1633518322,1,193.41,0,193.41;1633521828,1,194.0,4,194.0;1633556391,1,199.82,2,199.82;1633665658,0,195.1,4,195.1;1633796291,2,196.59,0,196.59;1633806663,3,242.54,12,242.54;1633808084,1,242.54,12,242.54;1633808198,1,242.56,3,242.56;1633819708,2,196.27,4,196.27;1634122397,1,294.33,9,294.33;1634201651,1,306.89,6,306.89;1634300947,1,322.34,5,322.34;1634489989,1,350.93,8,350.93;1634619782,1,9.96,10,9.96;1634855259,1,43.36,7,43.36;1634989671,1,61.9,11,61.9;1635967613,1,206.65,2,206.65;1636005323,1,213.13,4,213.13;1636060475,1,222.67,0,222.67;1636169859,1,241.73,12,241.73;1636348711,1,272.61,3,272.61;1636480280,1,294.6,9,294.6;1636548988,2,217.38,4,217.38;1636560868,1,307.66,6,307.66;1636660334,1,323.33,5,323.33;1636839954,1,350.49,8,350.49;1636966909,1,8.96,10,8.96;1637203449,1,42.25,7,42.25;1637344743,1,61.7,11,61.7;1637694190,0,241.7,12,241.7;1637861107,2,241.7,12,241.7;1638160763,2,247.17,0,247.17;1638492318,1,232.78,4,232.78;1638543473,1,241.74,12,241.74;1638603780,1,252.37,0,252.37;1638621780,1,255.54,2,255.54;1638840072,1,293.62,3,293.62;1638849332,1,295.2,9,295.2;1638934963,1,309.56,6,309.56;1639039972,1,326.58,5,326.58;1639194604,1,350.43,8,350.43;1639240140,3,295.32,9,295.32;1639317336,1,8.46,10,8.46;1639551048,1,41.31,7,41.31;1639599133,4,241.7,12,241.7'
var H02_str1 = '1624084961,1,192.63,10,12.63;1624269748,1,223.41,7,43.41;1624428394,1,250.7,11,70.7;1624459818,1,256.15,2,76.15;1624491556,3,116.12,9,296.12;1624559980,1,273.46,0,93.46;1624711758,1,299.21,3,119.21;1624775366,1,309.7,4,129.7;1625144894,4,132.35,6,312.35;1625611188,1,70.48,12,250.48;1625625347,3,132.02,6,312.02;1625933404,1,115.73,9,295.73;1626042733,1,131.71,6,311.71;1626174010,1,151.36,5,331.36;1626315402,1,173.1,8,353.1;1626441141,1,192.93,10,12.93;1626561980,0,115.56,9,295.56;1626634786,1,224.37,7,44.37;1626787310,1,249.8,11,69.8;1626957891,3,150.61,5,330.61;1627026799,1,290.19,2,110.19;1627094213,1,301.44,0,121.44;1627244082,2,115.37,9,295.37;1627254817,1,327.56,4,147.56;1627304641,1,335.42,3,155.42;1627573817,4,149.88,5,329.88;1627854601,2,130.21,6,310.21;1627884862,0,130.18,6,310.18;1627959127,1,68.91,12,248.91;1628287893,1,115.09,9,295.09;1628387387,1,129.75,6,309.75;1628511753,1,148.59,5,328.59;1628554776,3,172.68,8,352.68;1628644782,2,148.39,5,328.39;1628666133,1,172.66,8,352.66;1628791331,1,192.6,10,12.6;1628990298,1,224.78,7,44.78;1629129863,1,247.59,11,67.59;1629419310,0,147.23,5,327.23;1629633717,1,329.62,0,149.62;1629736960,1,345.69,4,165.69;1629770559,1,350.83,2,170.83;1629854018,2,172.33,8,352.33;1629907007,1,11.16,3,191.16;1629984257,3,192.21,10,12.21;1630300411,1,66.16,12,246.16;1630604570,4,172.1,8,352.1;1630647445,1,114.57,9,294.57;1630738475,1,127.95,6,307.95;1630851696,1,145.12,5,325.12;1631021653,1,171.97,8,351.97;1631075409,2,191.75,10,11.75;1631142960,1,191.72,10,11.72;1631342194,1,224.59,7,44.59;1631464503,1,244.74,11,64.74;1631611254,0,171.79,8,351.79;1632182081,1,358.23,0,178.23;1632222147,1,4.18,4,184.18;1632362681,1,24.59,2,204.59;1632390058,3,224.32,7,44.32;1632514533,1,45.95,3,225.95;1632641551,1,63.42,12,243.42;1633010064,1,114.32,9,294.32;1633093180,4,190.75,10,10.75;1633097397,1,126.95,6,306.95;1633202917,1,142.73,5,322.73;1633276241,0,190.65,10,10.65;1633384056,1,171.23,8,351.23;1633501126,1,190.53,10,10.53;1633697989,1,223.86,7,43.86;1633806663,3,242.54,11,62.54;1633808084,1,242.54,11,62.54;1634621140,1,10.16,2,190.16;1634711291,1,23.1,4,203.1;1634741800,1,27.43,0,207.43;1634989671,1,61.9,12,241.9;1635111724,1,78.56,3,258.56;1635372457,1,114.42,9,294.42;1635462176,1,127.15,6,307.15;1635567820,1,142.57,5,322.57;1635750283,1,170.65,8,350.65;1635865252,1,189.38,10,9.38;1636061154,1,222.79,7,42.79;1636070262,0,222.78,7,42.78;1636169859,1,241.73,11,61.73;1636818998,2,222.43,7,42.43;1637169785,4,222.26,7,42.26;1637205603,1,42.55,4,222.55;1637264853,1,50.73,2,230.73;1637312246,1,57.24,0,237.24;1637344743,1,61.7,12,241.7;1637664532,1,105.44,3,285.44;1637694190,0,241.7,11,61.7;1637732760,1,114.88,9,294.88;1637830294,1,128.55,6,308.55;1637861107,2,241.7,11,61.7;1637943816,1,144.83,5,324.83;1638114597,1,170.4,8,350.4;1638230092,1,188.61,10,8.61;1638428476,1,221.72,7,41.72;1638543473,1,241.74,11,61.74;1639599133,4,241.7,11,61.7'
var H03_str1 = '1620322354,12,251.0,10,11.0;1624086909,1,192.95,6,312.95;1624108948,1,196.54,2,76.54;1624186306,1,209.34,0,89.34;1624203318,1,212.18,5,332.18;1624283836,3,113.19,8,353.19;1624327005,1,233.2,8,353.2;1624330849,1,233.86,3,113.86;1624407395,1,247.06,4,127.06;1624440021,1,252.72,10,12.72;1624443076,0,92.17,5,332.17;1624619033,1,283.58,7,43.58;1624780648,1,310.56,11,70.56;1624820851,1,317.06,2,77.06;1624885463,4,130.49,12,250.49;1624953211,1,337.8,0,97.8;1625138534,1,5.2,3,125.2;1625174859,1,10.38,12,250.38;1625191081,1,12.68,4,132.68;1625215293,4,132.85,10,12.85;1625504218,1,55.85,9,295.85;1625514373,3,130.46,12,250.46;1625622425,1,72.02,6,312.02;1625688541,3,132.9,10,12.9;1625764145,1,91.66,5,331.66;1625915431,1,113.14,8,353.14;1626032297,1,130.17,12,250.17;1626050947,1,132.92,10,12.92;1626119110,2,91.41,5,331.41;1626258298,1,164.25,7,44.25;1626331574,1,175.62,9,295.62;1626338934,0,113.1,8,353.1;1626421360,1,189.78,11,69.78;1626431579,1,191.41,6,311.41;1626553382,1,211.02,5,331.02;1626613980,1,220.94,2,100.94;1626687197,1,233.05,8,353.05;1626712214,1,237.22,0,117.22;1626805818,1,252.92,10,12.92;1626876345,1,264.82,4,144.82;1626906330,1,269.89,3,149.89;1626992719,1,284.47,7,44.47;1627143216,1,309.52,11,69.52;1627144499,2,112.98,8,352.98;1627472501,1,0.92,2,120.92;1627507137,1,6.0,0,126.0;1627527508,1,8.97,12,248.97;1627680349,1,30.65,4,150.65;1627760454,1,41.73,3,161.73;1627767433,0,128.88,12,248.88;1627799724,2,128.89,12,248.89;1627858848,1,55.2,9,295.2;1627962069,2,132.78,10,12.78;1627967945,1,70.11,6,310.11;1627973609,3,164.68,7,44.68;1628105861,1,89.17,5,329.17;1628116878,0,132.76,10,12.76;1628271787,1,112.75,8,352.75;1628378964,1,128.5,12,248.5;1628407050,1,132.69,10,12.69;1628615928,1,164.76,7,44.76;1628680896,1,174.99,9,294.99;1628721934,3,174.98,9,294.98;1628761030,1,187.74,11,67.74;1628771545,1,189.43,6,309.43;1628887119,1,208.03,5,328.03;1629037992,1,232.56,8,352.56;1629159718,1,252.49,10,12.49;1629237067,1,265.2,0,145.2;1629344219,1,282.81,4,162.81;1629344265,1,282.81,2,162.81;1629356327,1,284.79,7,44.79;1629446759,2,164.79,7,44.79;1629482474,1,305.39,3,185.39;1629494277,1,307.3,11,67.3;1629605754,3,187.07,11,67.07;1629614257,4,164.79,7,44.79;1629722892,3,188.66,6,308.66;1629875002,1,6.47,12,246.47;1629987793,2,174.7,9,294.7;1630070361,1,34.49,0,154.49;1630174451,1,48.92,4,168.92;1630216203,1,54.65,9,294.65;1630249111,1,59.15,2,179.15;1630315552,1,68.23,6,308.23;1630384203,1,77.62,3,197.62;1630442902,1,85.7,5,325.7;1630630312,1,112.1,8,352.1;1630675108,2,185.95,11,65.95;1630724490,1,125.87,12,245.87;1630764830,1,131.89,10,11.89;1630805427,2,187.91,6,307.91;1630930777,4,174.53,9,294.53;1630933507,3,205.01,5,325.01;1630976064,1,164.66,7,44.66;1630978137,0,164.66,7,44.66;1631037366,1,174.51,9,294.51;1631102149,1,185.04,11,65.04;1631118532,1,187.72,6,307.72;1631221380,1,204.63,5,324.63;1631386222,1,231.86,8,351.86;1631506060,1,251.55,10,11.55;1631709039,1,284.51,7,44.51;1631765203,1,293.52,0,173.52;1631812733,1,301.11,4,181.11;1631834691,1,304.6,11,64.6;1631843559,0,174.41,9,294.41;1631943365,1,321.72,2,201.72;1632061536,1,340.01,3,220.01;1632178362,2,203.54,5,323.54;1632186233,4,183.91,11,63.91;1632219848,1,3.84,12,243.84;1632575356,1,54.34,9,294.34;1632606601,4,187.07,6,307.07;1632639821,0,183.42,11,63.42;1632641708,1,63.44,0,183.44;1632668190,1,67.05,6,307.05;1632671928,1,67.56,4,187.56;1632785074,1,83.01,5,323.01;1632802697,1,85.42,2,205.42;1632932026,3,231.37,8,351.37;1632953961,0,186.98,6,306.98;1632989186,1,111.35,8,351.35;1632995039,1,112.18,3,232.18;1633072879,1,123.37,12,243.37;1633123038,1,130.73,10,10.73;1633305894,2,202.67,5,322.67;1633339132,1,164.0,7,44.0;1633402986,1,174.31,9,294.31;1633454782,1,182.83,11,62.83;1633479335,1,186.9,6,306.9;1633572483,1,202.54,5,322.54;1633740762,1,231.13,8,351.13;1633854424,1,250.35,10,10.35;1634056416,1,283.71,7,43.71;1634174322,1,302.58,11,62.58;1634231320,1,311.54,2,191.54;1634284650,1,319.83,4,199.83;1634298371,0,202.34,5,322.34;1634301157,1,322.37,0,202.37;1634410143,3,250.07,10,10.07;1634566482,1,2.2,12,242.2;1634610988,4,202.33,5,322.33'
var H03_str2 = '1634639986,1,12.88,3,252.88;1634934916,1,54.38,9,294.38;1635027098,1,67.02,6,307.02;1635070613,1,72.96,2,192.96;1635139996,1,82.41,5,322.41;1635171058,1,86.65,4,206.65;1635216866,1,92.91,0,212.91;1635346054,1,110.73,8,350.73;1635426178,1,122.01,12,242.01;1635478897,1,129.55,10,9.55;1635577492,1,144.01,3,264.01;1635701575,1,162.96,7,42.96;1635740290,2,202.65,5,322.65;1635774159,1,174.48,9,294.48;1635819633,1,181.86,11,61.86;1635852687,1,187.3,6,307.3;1635944863,1,202.77,5,322.77;1636105993,1,230.59,8,350.59;1636212975,1,249.24,10,9.24;1636408057,1,282.62,7,42.62;1636524427,1,301.79,11,61.79;1636734209,0,230.5,8,350.5;1636763287,1,339.06,4,219.06;1636780959,1,341.72,2,221.72;1636849114,1,351.84,0,231.84;1636916975,1,1.76,12,241.76;1637195936,1,41.21,3,281.21;1637249856,2,230.45,8,350.45;1637294240,1,54.77,9,294.77;1637302072,3,282.2,7,42.2;1637392338,1,68.21,6,308.21;1637509916,1,84.26,5,324.26;1637670252,1,106.23,4,226.23;1637700614,1,110.42,8,350.42;1637769708,1,120.03,2,240.03;1637781677,1,121.7,12,241.7;1637789648,1,122.82,0,242.82;1637831392,1,128.7,10,8.7;1638058694,1,161.87,7,41.87;1638105273,1,168.97,3,288.97;1638144144,1,174.99,9,294.99;1638186868,1,181.71,11,61.71;1638195011,4,230.4,8,350.4;1638231823,1,188.89,6,308.89;1638240062,2,248.61,10,8.61;1638283073,0,248.6,10,8.6;1638332375,1,205.41,5,325.41;1638478667,1,230.4,8,350.4;1638582131,1,248.55,10,8.55;1638770157,1,281.58,7,41.58;1638887620,1,301.67,11,61.67;1639251591,1,358.89,4,238.89;1639270132,1,1.61,12,241.61;1639411397,1,21.86,0,261.86;1639477179,1,31.08,2,271.08'
var H04_str1 = '1623708052,6,313.11,7,43.11;1624136840,1,201.13,3,111.13;1624167451,1,206.2,9,296.2;1624224564,1,215.76,4,125.76;1624266519,1,222.86,6,312.86;1624379140,1,242.18,5,332.18;1624500535,1,263.2,8,353.2;1624614183,1,282.75,10,12.75;1624799769,1,313.66,7,43.66;1624970511,1,340.44,11,70.44;1624970511,1,340.44,12,250.44;1625021975,1,348.17,2,78.17;1625173837,1,10.24,0,100.24;1625285682,1,25.91,9,295.91;1625362778,4,133.91,7,43.91;1625377469,1,38.55,3,128.55;1625403973,1,42.17,6,312.17;1625413142,0,102.88,10,12.88;1625419683,1,44.32,4,134.32;1625547782,1,61.8,5,331.8;1625557164,2,83.17,8,353.17;1625703125,1,83.16,8,353.16;1625772313,3,134.07,7,44.07;1625843914,1,102.91,10,12.91;1626059430,1,134.18,7,44.18;1626230138,1,159.92,11,69.92;1626230138,1,159.92,12,249.92;1626401352,1,186.6,2,96.6;1626516638,1,205.06,0,115.06;1626519805,1,205.57,9,295.57;1626615903,1,221.26,6,311.26;1626689730,1,233.47,4,143.47;1626706306,2,102.92,10,12.92;1626712027,1,237.19,3,147.19;1626733909,1,240.84,5,330.84;1626865710,1,263.03,8,353.03;1626983448,1,282.91,10,12.91;1627173752,1,314.51,7,44.51;1627329024,1,339.22,11,69.22;1627329024,1,339.22,12,249.22;1627558717,3,158.94,11,68.94;1627558717,3,158.94,12,248.94;1627641822,1,25.26,9,295.26;1627727041,1,37.13,2,127.13;1627737359,1,38.55,0,128.55;1627750053,1,40.3,6,310.3;1627890039,1,59.46,5,329.46;1627911024,1,62.33,4,152.33;1628004284,1,75.1,3,165.1;1628042219,2,134.69,7,44.69;1628060084,1,82.8,8,352.8;1628202100,1,102.74,10,12.74;1628294237,0,134.72,7,44.72;1628420658,1,134.74,7,44.74;1628573149,1,158.08,11,68.08;1628573149,1,158.08,12,248.08;1628672348,4,157.88,11,67.88;1628672348,4,157.88,12,247.88;1628868025,1,204.95,9,294.95;1628956436,1,219.27,6,309.27;1629040775,1,233.02,0,143.02;1629069791,1,237.76,5,327.76;1629081920,2,157.59,11,67.59;1629081920,2,157.59,12,247.59;1629136603,1,248.7,2,158.7;1629153080,1,251.4,4,161.4;1629220717,1,262.51,8,352.51;1629282447,1,272.66,3,182.66;1629341961,1,282.44,10,12.44;1629540688,1,314.79,7,44.79;1629680100,1,336.89,11,66.89;1629680100,1,336.89,12,246.89;1630000919,1,24.69,9,294.69;1630098257,1,38.38,6,308.38;1630220166,0,156.16,11,66.16;1630220166,0,156.16,12,246.16;1630226169,1,56.02,5,326.02;1630307592,1,67.14,0,157.14;1630406143,1,80.63,4,170.63;1630417250,1,82.16,8,352.16;1630496788,1,93.18,2,183.18;1630559462,1,101.98,10,11.98;1630621449,1,110.82,3,200.82;1630783402,1,134.69,7,44.69;1630897610,3,204.53,9,294.53;1630917937,1,155.45,11,65.45;1630917937,1,155.45,12,245.45;1631220470,1,204.48,9,294.48;1631299979,1,217.62,6,307.62;1631401686,1,234.41,5,324.41;1631565560,1,261.27,0,171.27;1631568804,1,261.8,8,351.8;1631617043,1,269.64,4,179.64;1631690123,1,281.46,10,11.46;1631742050,1,289.81,2,199.81;1631851351,1,307.24,3,217.24;1631859273,3,217.34,6,307.34;1631897092,1,314.46,7,44.46;1632024122,1,334.26,11,64.26;1632024122,1,334.26,12,244.26;1632316305,2,204.36,9,294.36;1632361041,1,24.36,9,294.36;1632451186,1,37.12,6,307.12;1632566913,1,53.18,5,323.18;1632773454,1,81.42,8,351.42;1632880627,1,96.15,0,186.15;1632903418,1,99.31,4,189.31;1632914405,1,100.84,10,10.84;1633013318,1,114.79,2,204.79;1633044677,3,232.82,5,322.82;1633098381,2,204.32,9,294.32;1633145495,1,134.07,7,44.07;1633218165,1,145.05,3,235.05;1633270370,1,153.13,11,63.13;1633270370,1,153.13,12,243.13;1633582988,1,204.31,9,294.31;1633657031,1,216.89,6,306.89;1633748627,1,232.47,5,322.47;1633918615,1,261.08,8,351.08;1634035155,1,280.26,10,10.26;1634053832,1,283.29,2,193.29;1634084818,1,288.3,4,198.3;1634095507,1,290.02,0,200.02;1634244717,1,313.63,7,43.63;1634366971,1,332.45,11,62.45;1634366971,1,332.45,12,242.45;1634417961,1,340.16,3,250.16;1634472744,0,204.34,9,294.34;1634720134,1,24.36,9,294.36;1634809487,1,36.97,6,306.97;1634876369,4,204.37,9,294.37;1634920290,1,52.36,5,322.36;1635128025,1,80.78,8,350.78;1635266002,1,99.65,10,9.65;1635296757,3,260.74,8,350.74;1635311392,1,105.92,2,195.92;1635400906,1,118.43,4,208.43;1635451509,1,125.62,0,215.62;1635503084,1,133.05,7,43.05;1635587599,0,217.19,6,307.19;1635630315,1,151.97,11,61.97;1635630315,1,151.97,12,241.97;1635786018,1,176.39,3,266.39'
var H04_str2 = '1635845947,2,204.49,9,294.49;1635955038,1,204.51,9,294.51;1636029940,1,217.38,6,307.38;1636119167,1,232.89,5,322.89;1636278385,1,260.56,8,350.56;1636387485,1,279.17,10,9.17;1636559668,1,307.46,4,217.46;1636560487,1,307.59,2,217.59;1636563846,2,217.66,6,307.66;1636586033,4,217.67,6,307.67;1636591509,1,312.54,7,42.54;1636634761,1,319.34,0,229.34;1636715345,1,331.79,11,61.79;1636715345,1,331.79,12,241.79;1636963632,3,278.96,10,8.96;1636967160,1,8.99,3,278.99;1637006297,0,233.67,5,323.67;1637077850,1,24.72,9,294.72;1637173167,1,38.05,6,308.05;1637288551,1,53.99,5,323.99;1637451779,2,234.18,5,324.18;1637481900,1,80.43,8,350.43;1637615958,1,98.76,10,8.76;1637854322,1,131.96,7,41.96;1637896764,1,138.03,4,228.03;1637990615,1,151.7,11,61.7;1637990615,1,151.7,12,241.7;1638008850,1,154.4,2,244.4;1638016059,1,155.47,0,245.47;1638302159,1,200.38,3,290.38;1638330178,1,205.04,9,295.04;1638412982,1,219.06,6,309.06;1638508937,1,235.68,5,325.68;1638649332,1,260.41,8,350.41;1638752553,1,278.52,10,8.52;1638890158,2,260.41,8,350.41;1638944479,4,236.41,5,326.41;1638946835,1,311.52,7,41.52;1639043965,1,327.21,4,237.21;1639071850,1,331.61,12,241.61;1639071850,1,331.61,11,61.61;1639186532,1,349.22,0,259.22;1639236791,1,356.71,2,266.71;1639290061,0,260.44,8,350.44;1639436429,1,25.38,9,295.38;1639440141,1,25.9,3,295.9;1639542965,1,40.2,6,310.2;1640330220,6,311.09,7,41.09'
var H06_str1 = '1620322354,11,71.0,10,11.0;1624344201,1,236.15,9,296.15;1624440323,1,252.77,6,312.77;1624508893,6,312.73,10,12.73;1624552407,1,272.16,5,332.16;1624675847,1,293.2,8,353.2;1624780648,1,310.56,12,250.56;1624794352,1,312.79,10,12.79;1624885463,4,130.49,11,70.49;1624992440,1,343.75,7,43.75;1625074770,1,355.97,9,295.97;1625174859,1,10.38,11,70.38;1625188535,1,12.32,6,312.32;1625242329,1,19.88,2,79.88;1625329143,1,31.91,5,331.91;1625408762,1,42.83,0,102.83;1625484584,1,53.17,8,353.17;1625512457,0,103.97,7,43.97;1625514373,3,130.46,11,70.46;1625622077,1,71.97,3,131.97;1625628809,1,72.9,10,12.9;1625651234,1,75.98,4,135.98;1625852293,1,104.1,7,44.1;1626032297,1,130.17,11,70.17;1626181492,1,152.5,2,92.5;1626313588,1,172.82,0,112.82;1626421360,1,189.78,12,249.78;1626498249,1,202.09,4,142.09;1626512628,1,204.41,3,144.41;1626702031,1,235.52,9,295.52;1626773855,2,104.41,7,44.41;1626795073,1,251.11,6,311.11;1626910872,1,270.66,5,330.66;1627043540,1,293.0,8,353.0;1627143216,1,309.52,12,249.52;1627163808,1,312.89,10,12.89;1627363668,1,344.56,7,44.56;1627434765,1,355.32,9,295.32;1627527508,1,8.97,11,68.97;1627537996,1,10.48,6,310.48;1627673876,1,29.75,5,329.75;1627767433,0,128.88,11,68.88;1627799724,2,128.89,11,68.89;1627841595,1,52.85,8,352.85;1627975819,1,71.19,0,131.19;1627987396,1,72.78,10,12.78;1627992747,1,73.52,2,133.52;1628140344,1,94.0,4,154.0;1628215930,1,104.71,7,44.71;1628241446,1,108.37,3,168.37;1628378964,1,128.5,11,68.5;1628761030,1,187.74,12,247.74;1628842392,1,200.81,0,140.81;1628926381,1,214.39,2,154.39;1628960871,1,219.99,4,159.99;1629052322,1,234.9,9,294.9;1629083088,1,239.93,3,179.93;1629139181,1,249.12,6,309.12;1629250963,1,267.48,5,327.48;1629403140,1,292.46,8,352.46;1629494277,1,307.3,12,247.3;1629525673,1,312.37,10,12.37;1629605754,3,187.07,12,247.07;1629731062,1,344.79,7,44.79;1629796343,1,354.74,9,294.74;1629875002,1,6.47,11,66.47;1629889066,1,8.54,6,308.54;1630012459,1,26.33,5,326.33;1630198534,1,52.23,8,352.23;1630343655,1,72.07,10,12.07;1630543938,1,99.79,0,159.79;1630578778,1,104.72,7,44.72;1630631766,1,112.31,4,172.31;1630675108,2,185.95,12,245.95;1630724490,1,125.87,11,65.87;1630730710,1,126.79,2,186.79;1630843106,1,143.8,3,203.8;1631102149,1,185.04,12,245.04;1631369257,1,229.06,0,169.06;1631402001,1,234.46,9,294.46;1631424762,1,238.21,4,178.21;1631481467,1,247.52,6,307.52;1631543439,1,257.66,2,197.66;1631583467,1,264.19,5,324.19;1631647235,1,274.54,3,214.54;1631754074,1,291.74,8,351.74;1631834691,1,304.6,12,244.6;1631877483,1,311.37,10,11.37;1632090356,1,344.41,7,44.41;1632156307,1,354.38,9,294.38;1632186233,4,183.91,12,243.91;1632219848,1,3.84,11,63.84;1632242588,1,7.19,6,307.19;1632354137,1,23.37,5,323.37;1632554597,1,51.49,8,351.49;1632639821,0,183.42,12,243.42;1632696783,1,70.95,10,10.95;1632938039,1,104.14,7,44.14;1633072879,1,123.37,11,63.37;1633109642,1,128.75,0,188.75;1633124760,1,130.99,4,190.99;1633160851,3,234.32,9,294.32;1633208221,1,143.53,2,203.53;1633423569,1,177.68,3,237.68;1633454782,1,182.83,12,242.83;1633759511,1,234.32,9,294.32;1633833788,1,246.88,6,306.88;1633884543,1,255.4,2,195.4;1633893113,1,256.83,4,196.83;1633898687,1,257.76,0,197.76;1633926618,1,262.41,5,322.41;1634101834,1,291.03,8,351.03;1634153187,3,246.88,6,306.88;1634174322,1,302.58,12,242.58;1634205796,1,307.54,3,247.54;1634222521,1,310.16,10,10.16;1634433809,3,250.36,2,190.36;1634440462,1,343.54,7,43.54;1634513040,1,354.35,9,294.35;1634566482,1,2.2,11,62.2;1634598894,1,6.93,6,306.93;1634705914,1,22.34,5,322.34;1634909181,1,50.83,8,350.83;1635047140,1,69.75,10,9.75;1635291424,1,103.15,7,43.15;1635426178,1,122.01,11,62.01;1635448527,3,262.52,5,322.52;1635546707,1,139.44,2,199.44;1635618105,1,150.11,4,210.11;1635670656,1,158.15,0,218.15;1635819633,1,181.86,12,241.86;1635978734,1,208.56,3,268.56;1636128602,1,234.53,9,294.53;1636202765,1,247.46,6,307.46;1636214313,2,211.15,3,271.15;1636292624,1,263.02,5,323.02;1636355565,1,273.77,2,213.77;1636368510,1,275.96,4,215.96;1636434371,1,287.01,0,227.01;1636455637,1,290.54,8,350.54;1636524427,1,301.79,12,241.79;1636569898,1,309.1,10,9.1;1636748265,1,336.8,3,276.8'
var H06_str2 = '1636785810,1,342.44,7,42.44;1636868400,1,354.67,9,294.67;1636916975,1,1.76,11,61.76;1636959562,1,7.9,6,307.9;1637070907,1,23.74,5,323.74;1637096484,0,234.72,9,294.72;1637262827,1,50.45,8,350.45;1637396847,1,68.82,10,8.82;1637486034,2,234.82,9,294.82;1637639928,1,102.05,7,42.05;1637781677,1,121.7,11,61.7;1637910441,3,287.47,4,228.14;1637975089,6,308.67,10,8.67;1638110196,1,169.73,4,229.73;1638186868,1,181.71,12,241.71;1638225857,1,187.93,0,247.93;1638228809,1,188.41,2,248.41;1638256740,2,248.91,6,308.91;1638305173,3,290.4,8,350.4;1638314067,0,248.97,6,308.97;1638485504,1,231.59,3,291.59;1638505542,1,235.09,9,295.09;1638585930,1,249.22,6,309.22;1638680881,1,265.96,5,325.96;1638790878,4,235.18,9,295.18;1638821314,1,290.41,8,350.41;1638852122,1,295.67,4,235.67;1638887620,1,301.67,12,241.67;1638928553,1,308.5,10,8.5;1638978984,1,316.78,0,256.78;1639015598,1,322.69,2,262.69;1639135323,1,341.45,7,41.45;1639227112,1,355.27,3,295.27;1639227385,1,355.31,9,295.31;1639250654,2,266.96,5,326.96;1639270132,1,1.61,11,61.61;1639327786,1,9.96,6,309.96;1639450323,1,27.33,5,327.33;1639617645,1,50.46,8,350.46'
var H08_str1 = '1618178952,11,71.75,9,296.75;1618178952,12,251.75,9,296.75;1624061527,0,87.96,6,312.96;1624094041,0,88.32,7,43.32;1624112851,1,197.18,5,332.18;1624164191,1,205.65,11,70.65;1624164191,1,205.65,12,250.65;1624198217,1,211.33,2,76.33;1624239004,1,218.19,8,353.19;1624281372,1,225.39,0,90.39;1624353162,1,237.7,10,12.7;1624425427,1,250.19,3,115.19;1624430880,1,251.13,9,296.13;1624461905,3,115.7,11,70.7;1624461905,3,115.7,12,250.7;1624497711,1,262.71,4,127.71;1624526681,1,267.72,6,312.72;1624531408,1,268.54,7,43.54;1624566087,4,128.2,8,353.2;1624639997,1,287.14,5,332.14;1624690255,1,295.62,11,70.62;1624690255,1,295.62,12,250.62;1624726680,1,301.69,2,76.69;1624766195,1,308.2,8,353.2;1624849622,1,321.66,0,96.66;1624888572,1,327.8,10,12.8;1624971368,3,122.85,2,77.85;1624974182,1,340.99,9,295.99;1625024865,1,348.6,3,123.6;1625081086,1,356.89,4,131.89;1625084492,1,357.39,6,312.39;1625094178,1,358.8,7,43.8;1625221495,1,16.96,5,331.96;1625281957,1,25.39,11,70.39;1625281957,1,25.39,12,250.39;1625351344,3,128.18,8,353.18;1625358743,1,35.98,2,80.98;1625374788,1,38.18,8,353.18;1625519142,1,57.89,10,12.89;1625528381,1,59.15,0,104.15;1625613699,1,70.82,9,295.82;1625730339,1,86.94,6,311.94;1625742655,1,88.66,3,133.66;1625745553,1,89.06,7,44.06;1625756746,0,106.67,5,331.67;1625765143,1,91.8,4,136.8;1625834405,2,86.87,6,311.87;1625869750,1,106.59,5,331.59;1625930361,1,115.29,11,70.29;1625930361,1,115.29,12,250.29;1625983587,2,89.15,7,44.15;1626018458,1,128.13,8,353.13;1626068645,1,135.55,2,90.55;1626151317,1,147.93,10,12.93;1626208839,1,156.66,0,111.66;1626234907,1,160.65,9,295.65;1626337049,1,176.48,6,311.48;1626354913,1,179.28,7,44.28;1626383931,2,96.26,4,141.26;1626399935,1,186.38,4,141.38;1626410038,1,187.98,3,142.98;1626461036,1,196.11,5,331.11;1626489934,0,114.76,11,69.76;1626489934,0,114.76,12,249.76;1626514808,1,204.76,11,69.76;1626514808,1,204.76,12,249.76;1626596471,1,218.06,8,353.06;1626597637,2,100.6,3,145.6;1626716430,1,237.92,10,12.92;1626717955,1,238.18,2,103.18;1626764698,3,147.92,10,12.92;1626791429,1,250.5,9,295.5;1626807940,1,253.28,0,118.28;1626833400,2,105.74,5,330.74;1626883528,1,266.04,6,311.04;1626903694,1,269.45,7,44.45;1626969121,1,280.49,4,145.49;1626999215,1,285.56,5,330.56;1627003232,1,286.24,3,151.24;1627053418,1,294.65,11,69.65;1627053418,1,294.65,12,249.65;1627133833,1,307.98,8,352.98;1627204784,2,114.42,11,69.42;1627204784,2,114.42,12,249.42;1627256841,1,327.88,10,12.88;1627298603,4,147.88,10,12.88;1627336303,1,340.35,9,295.35;1627353685,1,343.03,2,118.03;1627398056,1,349.8,0,124.8;1627436443,1,355.57,6,310.57;1627463425,1,359.58,7,44.58;1627568273,1,14.84,4,149.84;1627568601,1,14.88,5,329.88;1627632139,1,23.9,11,68.9;1627632139,1,23.9,12,248.9;1627640466,1,25.07,3,160.07;1627653991,3,160.26,9,295.26;1627676873,0,127.88,8,352.88;1627732425,1,37.87,8,352.87;1627757490,2,127.87,8,352.87;1627877858,1,57.8,10,12.8;1627968399,1,70.18,9,295.18;1628076082,1,85.02,6,310.02;1628093917,1,87.5,0,132.5;1628109659,1,89.7,7,44.7;1628123209,1,91.59,2,136.59;1628211082,1,104.02,5,329.02;1628251419,1,109.81,4,154.81;1628278170,1,113.68,12,248.68;1628278170,1,113.68,11,68.68;1628354971,1,124.94,3,169.94;1628373798,1,127.73,8,352.73;1628505777,1,147.67,10,12.67;1628585592,1,160.02,9,295.02;1628610535,2,147.65,10,12.65;1628677827,1,174.51,6,309.51;1628686757,3,174.5,6,309.5;1628710984,1,179.77,7,44.77;1628741927,1,184.69,0,139.69;1628794896,1,193.17,5,328.17;1628819666,1,197.15,2,152.15;1628853803,1,202.65,11,67.65;1628853803,1,202.65,12,247.65;1628863927,1,204.28,4,159.28;1628946048,1,217.59,8,352.59;1628951530,4,159.93,9,294.93;1628982785,1,223.56,3,178.56;1629068338,1,237.52,10,12.52;1629072378,3,179.79,7,44.79;1629143797,1,249.88,9,294.88;1629194856,2,159.87,9,294.87;1629230072,1,264.05,6,309.05;1629265005,1,269.79,7,44.79;1629266748,5,327.46,10,12.46;1629334976,1,281.29,0,146.29;1629341416,1,282.35,5,327.35;1629403052,1,292.45,11,67.45;1629403052,1,292.45,12,247.45;1629435224,0,147.41,10,12.41;1629440188,1,298.51,4,163.51;1629448227,1,299.82,2,164.82;1629495103,1,307.44,8,352.44;1629584291,1,321.78,3,186.78'
var H08_str2 = '1629619328,1,327.34,10,12.34;1629698499,1,339.76,9,294.76;1629788905,1,353.61,6,308.61;1629829962,1,359.78,7,44.78;1629909229,1,11.49,5,326.49;1629920455,2,173.51,6,308.51;1629928750,3,191.46,5,326.46;1629955598,1,18.21,0,153.21;1629977207,1,21.31,11,66.31;1629977207,1,21.31,12,246.31;1630060287,1,33.08,4,168.08;1630090209,1,37.26,8,352.26;1630124729,1,42.06,2,177.06;1630234192,1,57.11,10,12.11;1630262454,1,60.98,3,195.98;1630285165,2,179.75,7,44.75;1630325810,1,69.63,9,294.63;1630424452,1,83.15,6,308.15;1630472020,1,89.73,7,44.73;1630526589,0,159.59,9,294.59;1630549320,1,100.55,5,325.55;1630622852,1,111.02,11,66.02;1630622852,1,111.02,12,246.02;1630635290,3,201.01,12,246.01;1630635290,3,201.01,11,66.01;1630657718,1,116.06,0,161.06;1630719896,4,172.96,6,307.96;1630732540,1,127.06,8,352.06;1630739532,1,128.11,4,173.11;1630840663,1,143.42,2,188.42;1630862849,1,146.85,10,11.85;1630943759,1,159.52,9,294.52;1630948077,1,160.21,3,205.21;1630949289,2,189.99,5,324.99;1631026605,1,172.77,6,307.77;1631069039,1,179.64,7,44.64;1631130937,1,189.75,5,324.75;1631192633,1,199.89,11,64.89;1631192633,1,199.89,12,244.89;1631271810,1,212.96,0,167.96;1631295554,1,216.89,8,351.89;1631329502,1,222.5,4,177.5;1631414975,1,236.6,10,11.6;1631444842,1,241.51,2,196.51;1631493206,1,249.45,9,294.45;1631546738,1,258.2,3,213.2;1631572962,1,262.48,6,307.48;1631602606,4,179.53,7,44.53;1631616358,1,269.53,7,44.53;1631668436,0,172.43,6,307.43;1631675347,1,279.08,5,324.08;1631730716,2,199.7,11,64.7;1631730716,2,199.7,12,244.7;1631741282,1,289.69,11,64.69;1631741282,1,289.69,12,244.69;1631812252,3,216.72,8,351.72;1631848015,1,306.71,8,351.71;1631866698,1,309.67,0,174.67;1631912291,1,316.85,4,181.85;1631972865,1,326.32,10,11.32;1632045628,1,337.57,2,202.57;1632057443,1,339.38,9,294.38;1632142006,1,352.23,6,307.23;1632170085,1,356.44,3,221.44;1632189811,1,359.38,7,44.38;1632251297,1,8.47,5,323.47;1632281520,0,179.36,7,44.36;1632321296,1,18.65,11,63.65;1632321296,1,18.65,12,243.65;1632446925,1,36.52,8,351.52;1632522752,1,47.09,0,182.09;1632556071,1,51.69,4,186.69;1632587488,1,56.01,10,11.01;1632684932,1,69.34,9,294.34;1632693220,1,70.47,2,205.47;1632735817,4,188.05,5,323.05;1632777884,1,82.02,6,307.02;1632830100,1,89.18,7,44.18;1632877088,1,95.66,3,230.66;1632893453,1,97.93,5,322.93;1632968534,1,108.43,11,63.43;1632968534,1,108.43,12,243.43;1633028784,0,187.83,5,322.83;1633093076,1,126.32,8,351.32;1633173792,3,234.49,0,189.49;1633217713,1,144.99,0,189.99;1633222248,1,145.68,10,10.68;1633229410,1,146.78,4,191.78;1633265228,3,235.66,10,10.66;1633299662,1,157.73,2,202.73;1633309715,1,159.32,9,294.32;1633388219,1,171.91,6,306.91;1633431355,1,178.96,7,43.96;1633483398,1,187.58,5,322.58;1633521392,1,193.93,3,238.93;1633535056,3,239.1,4,194.1;1633543828,1,197.7,11,62.7;1633543828,1,197.7,12,242.7;1633652742,1,216.16,8,351.16;1633725841,2,197.56,11,62.56;1633725841,2,197.56,12,242.56;1633765085,2,197.02,3,242.02;1633765882,1,235.4,10,10.4;1633799660,1,241.12,4,196.12;1633801992,1,241.51,2,196.51;1633802900,1,241.67,0,196.67;1633848274,1,249.32,9,294.32;1633880145,0,197.55,11,62.55;1633880145,0,197.55,12,242.55;1633923406,1,261.88,6,306.88;1633964895,1,268.75,7,43.75;1633990560,4,197.58,11,62.58;1633990560,4,197.58,12,242.58;1634017556,1,277.39,5,322.39;1634080430,1,287.59,11,62.59;1634080430,1,287.59,12,242.59;1634103270,1,291.26,3,246.26;1634196054,1,306.01,8,351.01;1634318965,1,325.11,10,10.11;1634323956,1,325.88,2,190.88;1634350893,3,249.34,9,294.34;1634387859,1,335.62,4,200.62;1634407555,1,338.59,0,203.59;1634412494,1,339.34,9,294.34;1634496629,1,351.92,6,306.92;1634541213,1,358.5,7,43.5;1634601644,1,7.33,5,322.33;1634669160,1,17.08,11,62.08;1634669160,1,17.08,12,242.08;1634754819,1,29.28,3,254.28;1634801545,1,35.85,8,350.85;1634938020,1,54.81,10,9.81;1634952727,1,56.83,2,191.83;1635044470,1,69.39,9,294.39;1635054420,1,70.75,4,205.75;1635096783,1,76.52,0,211.52;1635137310,1,82.05,6,307.05;1635182467,1,88.21,7,43.21;1635249957,1,97.44,5,322.44;1635319112,1,106.99,11,61.99;1635319112,1,106.99,12,241.99;1635387603,2,197.0,11,62.0;1635387603,2,197.0,12,242.0'
var H08_str3 = '1635415316,3,262.13,6,307.13;1635452167,1,125.71,8,350.71;1635459521,0,215.71,8,350.71;1635466184,1,127.72,3,262.72;1635580826,1,144.51,10,9.51;1635658444,1,156.27,2,201.27;1635679134,1,159.46,9,294.46;1635720341,1,165.91,4,210.91;1635760329,1,172.26,6,307.26;1635773306,1,174.34,0,219.34;1635795435,1,177.92,7,42.92;1635855230,1,187.72,5,322.72;1635909605,1,196.8,11,61.8;1635909605,1,196.8,12,241.8;1635916191,3,267.86,7,42.86;1636019695,1,215.61,8,350.61;1636071500,1,224.59,3,269.59;1636127099,1,234.27,10,9.27;1636214767,1,249.55,9,294.55;1636257456,1,256.95,2,211.95;1636276533,1,260.25,4,215.25;1636289658,1,262.51,6,307.51;1636316607,4,215.56,8,350.56;1636319727,1,267.66,7,42.66;1636338687,1,270.9,0,225.9;1636381066,1,278.09,5,323.09;1636432926,1,286.77,11,61.77;1636432926,1,286.77,12,241.77;1636450461,2,215.54,8,350.54;1636547590,1,305.53,8,350.53;1636643558,1,320.72,3,275.72;1636665074,1,324.06,10,9.06;1636767213,1,339.65,9,294.65;1636855873,1,352.84,6,307.84;1636869948,1,354.9,4,219.9;1636887007,1,357.4,7,42.4;1636897251,1,358.89,2,223.89;1636926265,3,278.59,5,323.59;1636961267,1,8.15,0,233.15;1636964615,1,8.63,5,323.63;1637021354,1,16.73,11,61.73;1637021354,1,16.73,12,241.73;1637028993,0,233.94,10,8.94;1637154553,1,35.46,8,350.46;1637197523,5,323.88,10,8.88;1637287584,1,53.85,10,8.85;1637312689,1,57.3,3,282.3;1637335520,0,237.51,3,282.51;1637403973,1,69.8,9,294.8;1637431623,2,233.81,10,8.81;1637502832,1,83.29,6,308.29;1637530747,1,87.1,7,42.1;1637554207,1,90.31,4,225.31;1637620600,1,99.4,5,324.4;1637644929,1,102.74,2,237.74;1637671826,1,106.44,0,241.44;1637673722,1,106.7,11,61.7;1637673722,1,106.7,12,241.7;1637808093,1,125.41,8,350.41;1637815727,3,286.7,11,61.7;1637815727,3,286.7,12,241.7;1637897279,2,242.36,3,287.36;1637935874,1,143.68,10,8.68;1638000596,1,153.17,3,288.17;1638046037,1,159.96,9,294.96;1638136570,1,173.81,6,308.81;1638155922,1,176.83,7,41.83;1638210890,1,185.53,4,230.53;1638240335,1,190.27,5,325.27;1638279912,1,196.72,11,61.72;1638279912,1,196.72,12,241.72;1638318474,2,250.04,9,295.04;1638324474,1,204.09,0,249.09;1638331584,1,205.28,2,250.28;1638391594,1,215.4,8,350.4;1638407499,0,250.06,9,295.06;1638496794,1,233.56,10,8.56;1638574146,1,247.14,3,292.14;1638587860,4,233.55,10,8.55;1638591023,1,250.12,9,295.12;1638671425,1,264.3,6,309.3;1638684581,1,266.62,7,41.62;1638760667,1,279.93,4,234.93;1638767428,1,281.11,5,326.11;1638799723,1,286.7,11,61.7;1638799723,1,286.7,12,241.7;1638881449,1,300.63,0,255.63;1638909997,1,305.41,8,350.41;1638912415,1,305.82,2,260.82;1639020579,1,323.49,10,8.49;1639125221,1,339.9,3,294.9;1639127713,1,340.28,9,295.28;1639129471,2,264.76,6,309.76;1639221006,2,266.42,7,41.42;1639224288,1,354.86,6,309.86;1639234818,1,356.42,7,41.42;1639342865,1,12.13,5,327.13;1639361387,1,14.78,4,239.78;1639374423,1,16.63,11,61.63;1639374423,1,16.63,12,241.63;1639508674,1,35.45,8,350.45;1639528847,1,38.25,0,263.25;1639602268,1,48.36,2,273.36;1639639389,1,53.44,10,8.44;1639710106,0,265.38,6,310.38;1639783139,0,266.24,7,41.24'

// @function get the start time for each harmonic signal
// @param harmonic is an integer identifying the harmonic
// @returns the starting timestamp of the harmonic data
export import_start_time(int harmonic) =>
    switch harmonic
        1 => 1624428394
        2 => 1624084961
        3 => 1620322354
        4 => 1623708052
        6 => 1620322354
        8 => 1618178952
        => 9999999999

// @function access point for pre-processed data imported here by copy paste
// @param index is the current data index, use 0 to initialize
// @param harmonic is the data set to index, use 0 to initialize
// @param get_length when true returns the length of the indicated harmonic array rather than the data
// @returns the data from the indicated harmonic array starting at index, and the starting timestamp of that data
export import_signal(int index, int harmonic, bool get_length=false) =>
    var event_str = ''
    var H_array = array.new_string(0)

    // the arrays must be defined in the function as libraries cannot export global variables
    var H01_array = array.new_string(0)
    var H02_array = array.new_string(0)
    var H03_array = array.new_string(0)
    var H04_array = array.new_string(0)
    var H06_array = array.new_string(0)
    var H08_array = array.new_string(0)

    // initialize the data if the array is zero length. 
    // This is call dependant which means it is also harmonic dependant
    if harmonic == 1 and array.size(H01_array) == 0
        stringArrayAppend(H01_array, H01_str1, ';')
    if harmonic == 2 and array.size(H02_array) == 0
        stringArrayAppend(H02_array, H02_str1, ';')
    if harmonic == 3 and array.size(H03_array) == 0
        stringArrayAppend(H03_array, H03_str1, ';')
        stringArrayAppend(H03_array, H03_str2, ';')
    if harmonic == 4 and array.size(H04_array) == 0
        stringArrayAppend(H04_array, H04_str1, ';')
        stringArrayAppend(H04_array, H04_str2, ';')
    if harmonic == 6 and array.size(H06_array) == 0
        stringArrayAppend(H06_array, H06_str1, ';')
        stringArrayAppend(H06_array, H06_str2, ';')
    if harmonic == 8 and array.size(H08_array) == 0
        stringArrayAppend(H08_array, H08_str1, ';')
        stringArrayAppend(H08_array, H08_str2, ';')
        stringArrayAppend(H08_array, H08_str3, ';')

    H_array := switch harmonic
        1 => H01_array
        2 => H02_array
        3 => H03_array
        4 => H04_array
        6 => H06_array
        8 => H08_array
        => array.new_string(0)

    // [_t, _c] = dbug.init(size=50, visible=true)
    // _msg = str.format('index {0} harmonic {1} flag {2} array length {3} {4}', index, harmonic, get_length, array.size(H_array), array.size(H04_str))

    event_str := if get_length
        str.tostring(array.size(H_array))      // return the length of the array as a string
    else if index < array.size(H_array)
        array.get(H_array, index)
    else
        ''

    // _msg += str.format(' item length {0} array length {1}', str.length(event_str), array.size(H_array))
    // dbug.queue(_c, 'inDB: ' + _msg)
    // dbug.update(_t, _c)
    // event_str


// *** Library Purpose and How to Use ***

// CAUTION: Every unique call of the import_signal function initializes the data into a new dataset in the local scope of the function.
// That can consume time and memory to parse the strings and fill the arrays, so be sure to call the function as few times as possible.
// Keep in mind that you can call the function as many times as required in a loop as it is the same call and initializes the data on the first iteration of the loop.
// Calling the function in different places in your script is what counts as different calls.

// The intention is to create a (very limited) way to import external data into pine script
// As far as I can tell, putting the data into a library frees up resources in your main script so you can have more code!
// It can also be thought of as using libraries as classes to encapsulate the data and even some of the functionality around that data.
// This example is limited but you could build a sophisticated data handling system in a set of libraries.

// You can organize the data in any way that suits your needs.
// In this example the data starts with a timestamp and then follows with data related to that timestamp.
// Sections use a semi-colon as a separator character and the data in each section uses a comma.

// After importing the library into your main script:
// import ubiquity/Signal_Data_2021_09_09__2021_11_18/7 as sdata

// The data store must be initialized in your main script inside an if barstate.isfirst block:
// if barstate.isfirst
//     // initialize the data
//     sdata.import_signal(0, 0)

// The initialization runs the library function and ensures the barstate.isfirst code in that function
// is executed so the imported data strings are parsed into the string arrays.
// After that, whenever the function is called it accesses the data from the array.

// Then the data can be used - This following example script is not part of this library. 
// It is an example of how to use the data in the main script.

// get_signal(harmonic) =>
//     // the index variable is the offset into the array and is maintained uniquely across function calls
//     var index = 0
//     var in_session = false
//     var start_time = sdata.import_start_time(harmonic)

//     timestamp = start_time
//     fid = 0
//     fwave = 0.0
//     sid = 0
//     swave = 0.0
//     is_signal = false

//     var signal_str = ''
//     var signal = array.new_string(0)

//     // catch up to the start of the data
//     signal_str := sdata.import_signal(index, harmonic)
//     while not in_session and str.length(signal_str) > 0 and topen > timestamp
//         // split the data string
//         signal := str.split(signal_str, ',')
//         // convert the string to a number
//         timestamp := int(str.tonumber(array.get(signal, 0)))
//         if topen > timestamp
//             index += 1
//             signal_str := sdata.import_signal(index, harmonic)

//     // if the first bar of the timeframe starts before the first signal, activate the session right away
//     if not in_session and not (topen < start_time)
//         in_session := true

//     if in_session and str.length(signal_str) > 0
//         // split the data string
//         signal := str.split(signal_str, ',')
//         // convert the first string to a number
//         timestamp := int(str.tonumber(array.get(signal, 0)))

//         if tclose[2] < timestamp and timestamp <= tclose
//             // when the signal is triggered convert the remaining strings to numbers
//             fid := int(str.tonumber(array.get(signal, 1)))
//             fwave := str.tonumber(array.get(signal, 2))
//             sid := int(str.tonumber(array.get(signal, 3)))
//             swave := str.tonumber(array.get(signal, 4))

//             index += 1
//             is_signal := true

//     [index, is_signal, fid, fwave, sid, swave]

// // exposing the index to the global namespace allows it to be used in more function calls (not shown in this example)

// [H01_index, is_H01_signal, H01_p1id, H01_p1wave, H01_p2id, H01_p2wave] = get_signal(1)
// bgcolor(color=show_signal_bgcolor and is_H01_signal ? color.white : na, title='H01 Signal')

// [H02_index, is_H02_signal, H02_p1id, H02_p1wave, H02_p2id, H02_p2wave] = get_signal(2)
// bgcolor(color=show_signal_bgcolor and is_H02_signal ? color.orange : na, title='H02 Signal')

// [H03_index, is_H03_signal, H03_p1id, H03_p1wave, H03_p2id, H03_p2wave] = get_signal(3)
// bgcolor(color=show_signal_bgcolor and is_H03_signal ? color.navy : na, title='H03 Signal')

