initial diagonal work (unfinished)

This commit is contained in:
Tim
2024-04-30 21:30:16 -04:00
parent e8dafc0732
commit 056a4e299d
11 changed files with 357 additions and 165 deletions

View File

@@ -27,6 +27,7 @@ function changeSymbol(symbol) {
lastSymbolChangedArgs = info
symbolChangedCbs.forEach((cb)=>cb(info))
co.selectedSymbol = info
co.meanRange = chartMeanRange()
}
@@ -364,3 +365,21 @@ export function deleteShapeId(id) {
// console.log('removing entity', id)
chart.removeEntity(id)
}
function chartMeanRange() {
let range = 0
const series = chart.getSeries()
const bars = series.data().bars();
const final = Math.max(bars.size() - 50, 0)
let count = 0
for (let barIndex = bars.size() - 1; barIndex >= final; barIndex--) {
count++
const [_time, _open, high, low, _close, _volume, _ms] = bars.valueAt(barIndex)
range += (high - low)
}
if (count > 0)
range /= count
else
range = 1
return range
}