Skip to content

Commit

Permalink
NOVA-678: fix 24h_close_change pine for very small numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
stimofeev-tv committed Dec 18, 2024
1 parent 9b88ea6 commit bed4f1e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion links/24h_volume.pine.link
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ plot(close24hChangeAbs, title = "24h_close_change_abs", style = plot.style_colum

// 24h close change
float close24hChange = na
if na(close24hChangeAbs) or close24hPrev == 0 or (close24hPrev < 0 and close > 0)
float close24hPrevToCompare = close24hPrev * 1e+36 // for comparing very small numbers since pine has limited precision (1e-10)
if na(close24hChangeAbs) or close24hPrevToCompare == 0 or (close24hPrevToCompare < 0 and close > 0)
na
else
close24hChange := (close24hChangeAbs / math.abs(close24hPrev)) * 100
Expand Down
Loading

0 comments on commit bed4f1e

Please sign in to comment.