Skip to content

Commit e5780a8

Browse files
authored
Update README.md
1 parent 22dba34 commit e5780a8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

faq_and_code/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,30 @@ plotchar(close, "close", "", location.top, size = size.tiny)
9696
```
9797
![.](built-ins_Chart_vs_built-in_discrepancies.png "Built-ins - Chart vs built-in discrepancies")
9898

99+
You can also use this version of the function which returns rounded OHLC values in a single call:
100+
```js
101+
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
102+
// © PineCoders
103+
104+
//@version=4
105+
study("My Script", precision = 8)
106+
f_ohlcRoundedToTick() => [round(open / syminfo.mintick) * syminfo.mintick, round(high / syminfo.mintick) * syminfo.mintick, round(low / syminfo.mintick) * syminfo.mintick, round(close / syminfo.mintick) * syminfo.mintick]
107+
f_color(_v1, _v2) => _v1 != _v2 ? color.red : color.blue
108+
109+
[o, h, l, c] = f_ohlcRoundedToTick()
110+
111+
plotchar(o, "o", "", location.top, f_color(o, open))
112+
plotchar(open, "open", "", location.top, f_color(o, open))
113+
plotchar(h, "h", "", location.top, f_color(h, high))
114+
plotchar(high, "high", "", location.top, f_color(h, high))
115+
plotchar(l, "l", "", location.top, f_color(l, low))
116+
plotchar(low, "low", "", location.top, f_color(l, low))
117+
plotchar(c, "c", "", location.top, f_color(c, close))
118+
plotchar(close, "close", "", location.top, f_color(c, close))
119+
120+
bgcolor(o != open or h != high or l != low or c != close ? color.red : na)
121+
```
122+
99123
**[Back to top](#table-of-contents)**
100124

101125

0 commit comments

Comments
 (0)