Skip to content

Commit 4fa3860

Browse files
authored
Update README.md
1 parent 491ca90 commit 4fa3860

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

coding_conventions/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,33 @@ plot(signal, color = color.orange)
8383

8484
## Naming Conventions
8585

86+
### Constants
87+
88+
Constants are variables whose value will not change during script execution. Use all caps snake case for constants, and declare them using the `var` keyword so they are only initialized when the script executes at bar zero, or when [``barstate.isfirst``](https://www.tradingview.com/pine-script-reference/v4/#var_barstate{dot}isfirst) is true. Examples:
89+
90+
```js
91+
// ———————————————————— Constants, global arrays and inputs {
92+
93+
// ————— Input `options` selections.
94+
var string RT1 = "MAs and Oscillators"
95+
var string RT2 = "MAs"
96+
var string RT3 = "Oscillators"
97+
98+
var string ON = "On"
99+
var string OFF = "Off"
100+
101+
// Levels determining "Strong Buy/Sell" and "Buy/Sell" ratings.
102+
var float LEVEL_STRONG = 0.5
103+
var float LEVEL_WEAK = 0.1
104+
105+
// Color constants.
106+
var color C_AQUA = #0080FFff
107+
var color C_BLACK = #000000ff
108+
// }
109+
```
110+
111+
The curly braces at the beginning and end of this code section allow you to collapse/expand that code section using the little triangle in the Editor's left margin.
112+
86113
### Variable Names
87114

88115
We recommend using camelCase for variable names. Example: `emaLength`, `obLevel`, `showSignal2`, `aLongVariableName`.

0 commit comments

Comments
 (0)