Skip to content

Commit 6819e92

Browse files
authored
Update README.md
1 parent 7d14826 commit 6819e92

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: coding_conventions/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ We also recommend declaring the type of variables explicitly—even if the compi
128128
study("", "", true)
129129

130130
// ————— Calculate all-time high.
131-
// This line declares the variable on the first bar only.
131+
// The first line declares the variable on the first bar only.
132132
// On successive bars, its value is thus preserved bar to bar, until it is assigned a new value.
133-
var float allTimeHigh = high
134-
allTimeHigh := max(allTimeHigh, high)
133+
var float allTimeHi = high
134+
allTimeHi := max(allTimeHi, high)
135135

136136
// ————— Detect changes in the all-time high.
137-
bool newAllTimeHigh = change(allTimeHigh)
137+
bool newAllTimeHi = change(allTimeHi)
138138

139-
plot(allTimeHigh)
140-
plotchar(newAllTimeHigh, "newAllTimeHigh", "", location.top, size = size.tiny)
139+
plot(allTimeHi)
140+
plotchar(newAllTimeHi, "newAllTimeHi", "", location.top, size = size.tiny)
141141
```
142142

143143
We first calculate the all-time high. We start by declaring the ``allTimeHigh`` variable as being of type "float", and assign it the value of the bar's ``high`` at bar zero. This line will no longer be executed after bar zero. When the script runs on each successive bar and on each realtime update of the feed, the variable is re-assigned with the maximum of either the variable's last value or the current bar's ``high``.

0 commit comments

Comments
 (0)