[{"data":1,"prerenderedAt":257},["ShallowReactive",2],{"indicators:cookbook/historical-returns":3},{"slug":4,"filePath":5,"frontmatter":6,"rawMarkdown":11,"tree":12},"cookbook/historical-returns","cookbook/historical-returns.md",{"title":7,"description":8,"order":9,"section":10},"Historical Returns Matrix","In Indicators this is a table, not a matrix pane: there is no renderer that ignores the time axis, so the kScript (legacy) month-by-year grid has no Indicator…",64,"cookbook","---\ntitle: \"Historical Returns Matrix\"\ndescription: \"In Indicators this is a table, not a matrix pane: there is no renderer that ignores the time axis, so the kScript (legacy) month-by-year grid has no Indicator…\"\norder: 64\nsection: \"cookbook\"\n---\n\n\u003C!-- source: docs/indicators/cookbook/historical-returns.md; generated by packages/cli/scripts/gen-indicator-docs.ts, do not edit -->\n\n# Historical Returns Matrix\n\nIn Indicators this is a table, not a matrix pane: there is no renderer that ignores the time axis, so the kScript (legacy) month-by-year grid has no Indicator form today.\n\nThe nearest form is `render.table` over string slots: bucket bars into months from `time.bar_open_sec`, keep the last N monthly returns in module-level variables, write them into `rows x cols` string slots in `finalize()`, and the chart shows the newest complete row of the table ([Plotting](../functions/plotting.md)).\n\nWhat stays on kScript (legacy): `requestBars` for daily history independent of the chart interval, `plotMatrix` with its summary rows and the highlighted forming month; run the original with **Use kScript engine**.\n",{"type":13,"children":14,"data":250,"position":252},"root",[15,25,28,29,46,47,169,170],{"type":16,"value":17,"position":18},"comment"," source: docs/indicators/cookbook/historical-returns.md; generated by packages/cli/scripts/gen-indicator-docs.ts, do not edit ",{"start":19,"end":22},{"line":20,"column":20,"offset":21},1,0,{"line":20,"column":23,"offset":24},134,133,{"type":26,"value":27},"text","\n",{"type":26,"value":27},{"type":30,"tagName":31,"properties":32,"children":33,"position":43},"element","p",{},[34],{"type":26,"value":35,"position":36},"In Indicators this is a table, not a matrix pane: there is no renderer that ignores the time axis, so the kScript (legacy) month-by-year grid has no Indicator form today.",{"start":37,"end":40},{"line":38,"column":20,"offset":39},5,164,{"line":38,"column":41,"offset":42},171,334,{"start":44,"end":45},{"line":38,"column":20,"offset":39},{"line":38,"column":41,"offset":42},{"type":26,"value":27},{"type":30,"tagName":31,"properties":48,"children":49,"position":166},{},[50,59,73,80,93,100,113,120,133,140,159],{"type":26,"value":51,"position":52},"The nearest form is ",{"start":53,"end":56},{"line":54,"column":20,"offset":55},7,336,{"line":54,"column":57,"offset":58},21,356,{"type":30,"tagName":60,"properties":61,"children":62,"position":70},"code",{},[63],{"type":26,"value":64,"position":65},"render.table",{"start":66,"end":67},{"line":54,"column":57,"offset":58},{"line":54,"column":68,"offset":69},35,370,{"start":71,"end":72},{"line":54,"column":57,"offset":58},{"line":54,"column":68,"offset":69},{"type":26,"value":74,"position":75}," over string slots: bucket bars into months from ",{"start":76,"end":77},{"line":54,"column":68,"offset":69},{"line":54,"column":78,"offset":79},84,419,{"type":30,"tagName":60,"properties":81,"children":82,"position":90},{},[83],{"type":26,"value":84,"position":85},"time.bar_open_sec",{"start":86,"end":87},{"line":54,"column":78,"offset":79},{"line":54,"column":88,"offset":89},103,438,{"start":91,"end":92},{"line":54,"column":78,"offset":79},{"line":54,"column":88,"offset":89},{"type":26,"value":94,"position":95},", keep the last N monthly returns in module-level variables, write them into ",{"start":96,"end":97},{"line":54,"column":88,"offset":89},{"line":54,"column":98,"offset":99},180,515,{"type":30,"tagName":60,"properties":101,"children":102,"position":110},{},[103],{"type":26,"value":104,"position":105},"rows x cols",{"start":106,"end":107},{"line":54,"column":98,"offset":99},{"line":54,"column":108,"offset":109},193,528,{"start":111,"end":112},{"line":54,"column":98,"offset":99},{"line":54,"column":108,"offset":109},{"type":26,"value":114,"position":115}," string slots in ",{"start":116,"end":117},{"line":54,"column":108,"offset":109},{"line":54,"column":118,"offset":119},210,545,{"type":30,"tagName":60,"properties":121,"children":122,"position":130},{},[123],{"type":26,"value":124,"position":125},"finalize()",{"start":126,"end":127},{"line":54,"column":118,"offset":119},{"line":54,"column":128,"offset":129},222,557,{"start":131,"end":132},{"line":54,"column":118,"offset":119},{"line":54,"column":128,"offset":129},{"type":26,"value":134,"position":135},", and the chart shows the newest complete row of the table (",{"start":136,"end":137},{"line":54,"column":128,"offset":129},{"line":54,"column":138,"offset":139},282,617,{"type":30,"tagName":141,"properties":142,"children":144,"position":154},"a",{"href":143},"../functions/plotting.md",[145],{"type":26,"value":146,"position":147},"Plotting",{"start":148,"end":151},{"line":54,"column":149,"offset":150},283,618,{"line":54,"column":152,"offset":153},291,626,{"start":155,"end":156},{"line":54,"column":138,"offset":139},{"line":54,"column":157,"offset":158},318,653,{"type":26,"value":160,"position":161},").",{"start":162,"end":163},{"line":54,"column":157,"offset":158},{"line":54,"column":164,"offset":165},320,655,{"start":167,"end":168},{"line":54,"column":20,"offset":55},{"line":54,"column":164,"offset":165},{"type":26,"value":27},{"type":30,"tagName":31,"properties":171,"children":172,"position":247},{},[173,182,195,202,215,222,240],{"type":26,"value":174,"position":175},"What stays on kScript (legacy): ",{"start":176,"end":179},{"line":177,"column":20,"offset":178},9,657,{"line":177,"column":180,"offset":181},33,689,{"type":30,"tagName":60,"properties":183,"children":184,"position":192},{},[185],{"type":26,"value":186,"position":187},"requestBars",{"start":188,"end":189},{"line":177,"column":180,"offset":181},{"line":177,"column":190,"offset":191},46,702,{"start":193,"end":194},{"line":177,"column":180,"offset":181},{"line":177,"column":190,"offset":191},{"type":26,"value":196,"position":197}," for daily history independent of the chart interval, ",{"start":198,"end":199},{"line":177,"column":190,"offset":191},{"line":177,"column":200,"offset":201},100,756,{"type":30,"tagName":60,"properties":203,"children":204,"position":212},{},[205],{"type":26,"value":206,"position":207},"plotMatrix",{"start":208,"end":209},{"line":177,"column":200,"offset":201},{"line":177,"column":210,"offset":211},112,768,{"start":213,"end":214},{"line":177,"column":200,"offset":201},{"line":177,"column":210,"offset":211},{"type":26,"value":216,"position":217}," with its summary rows and the highlighted forming month; run the original with ",{"start":218,"end":219},{"line":177,"column":210,"offset":211},{"line":177,"column":220,"offset":221},192,848,{"type":30,"tagName":223,"properties":224,"children":225,"position":235},"strong",{},[226],{"type":26,"value":227,"position":228},"Use kScript engine",{"start":229,"end":232},{"line":177,"column":230,"offset":231},194,850,{"line":177,"column":233,"offset":234},212,868,{"start":236,"end":237},{"line":177,"column":220,"offset":221},{"line":177,"column":238,"offset":239},214,870,{"type":26,"value":241,"position":242},".",{"start":243,"end":244},{"line":177,"column":238,"offset":239},{"line":177,"column":245,"offset":246},215,871,{"start":248,"end":249},{"line":177,"column":20,"offset":178},{"line":177,"column":245,"offset":246},{"quirksMode":251},false,{"start":253,"end":254},{"line":20,"column":20,"offset":21},{"line":255,"column":20,"offset":256},10,872,1790157166150]