ProRealCode Studio is on its way. As soon as it is published, this button will take you straight to its Chrome Web Store page.
A period, a colour, a threshold: whoever writes a code can turn any of them into a setting. Whoever uses the code then changes it from a window on the chart, copy by copy, without reading a line.
Declares each setting once, in the code: its name, its starting value, its title, its type. “Variables”, in the editor's header, does it as a form (sections 01 to 03).
Opens ⚙ Settings for a copy on the chart and changes its values. The code does not change; another copy of it keeps its own values (sections 04 and 05).
input(period, 20, "MA period", int)
period, the name. The rest of the code reads it like any variable: Average[period](close).20, the starting value. It is what the code uses until somebody changes it."MA period", the title shown in ⚙ Settings. Leave it out and the name is shown instead.int, the type. It decides the control in ⚙ Settings. Leave it out and the setting is a float.| Type | In ⚙ Settings | The value |
|---|---|---|
int | A whole-number field | Rounded to a whole number. |
float | A number field | As typed. |
bool | A switch | 1 when on, 0 when off. |
matype | A list of averages | 0 Simple (SMA), 1 Exponential (EMA), 2 Weighted (WMA), 3 Wilder, 4 Triangular, 5 End point, 6 Time series, 7 Hull, 8 ZeroLag. |
string | A text field | Text: a label, a table title, a word. |
color | A colour picker | A colour, written "#ff8800" in the code. |
timeframe | A list of timeframes | Section 05. |
instrument | A list of instruments | Section 05. |
input(). A code that declares a setting this way carries the “Studio Only” chip (chapter 06): it runs in ProRealCode Studio, not when pasted into the platform.
1
2
3
4
5
6
7
bool takes a switch as its starting value.input() lines at the top of the code. None yet: it says so.Write them after the type, in any order, or fill them in under “⋯” in ƒx Variables.
| Attribute | On types | In ⚙ Settings |
|---|---|---|
options | int, float, string | A list of the values written: nothing else can be picked. |
minval | int, float | The lowest value. A smaller one typed in is raised to it. |
maxval | int, float | The highest value. Type 500 under maxval = 200 and the field reads 200. |
step | int, float | How far the field's arrows move the value. A value typed by hand is kept as typed. |
group | all | A heading, in the order the code declares them. |
inline | all | Settings that share the same word sit on one line. |
tooltip | all | A help text behind an ⓘ next to the title. |
input(len, 20, "Length", int, minval = 5, maxval = 200, step = 5, group = "Averages", tooltip = "Bars in the average")input(method, "EMA", "Type", string, options = ["SMA", "EMA", "WMA"], group = "Averages")input(tint, "#ff8800", "Colour", color, group = "Appearance")
input() lines that open the code, one after the other. A line written further down still works in ⚙ Settings, but the window does not show it and leaves it as written. A misspelt attribute stops the code with an error that lists the seven.
1
2
3
| Settings move THIS instance only. | Another copy of the code keeps its own values. |
| ƒx Edit declarations | Opens ƒx Variables, when this code is the one open in the editor. |
| ↺ Reset to defaults | Puts back the starting values of this copy. Greyed while nothing has changed. |
A code that declares a timeframe setting gets a list of timeframes in ⚙ Settings. A code that declares none gets no list: nothing is added behind your back.
The setting moves whatever the code wrote it into. Here, the RSI is computed on hourly bars, whatever the chart shows.
input(mytf, "1 hour", "Timeframe", timeframe) TIMEFRAME(mytf) h1rsi = RSI[14](close) TIMEFRAME(default) RETURN h1rsi AS "H1 RSI"
“Chart timeframe”, then 1, 2, 3, 5, 10, 15 and 30 minutes, 1, 2, 3, 4, 6, 8 and 12 hours, 1 day, 1 week, 1 month. A timeframe shorter than the chart's is greyed out: on a 15-minute chart, 1 to 10 minutes.
A code that declares an instrument setting and passes it to MarketData() gets a list that starts with “Chart instrument”, followed by your chart's ticker, then the other instruments Studio can read.
ƒx Variables, for the code: “⚙ Try values” jumps to the copy on the chart. ⚙ Settings, for a copy: “ƒx Edit declarations” jumps back to the code.
Renamed or removed a setting in ƒx Variables? A value you had set in ⚙ Settings is kept; “↺ Reset to defaults” clears it. Changed its type? The value goes back to the starting one.
The code has no input() line. Add one, for instance with ƒx Variables, then run the code.
That value is written in the code, not declared as a setting. Declare it with input() and each copy gets its own.
Fix the errors the editor shows first (chapter 09), then reopen the window.
The code is not on the chart yet. Click “Run”, then try again.
Chapter 09 · Finding and fixing errors