initial diagonal work (unfinished)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user