Soon available

Not on the Chrome Web Store yet

ProRealCode Studio is on its way. As soon as it is published, this button will take you straight to its Chrome Web Store page.

Chapter 06 · Part II — Writing code

Write it, read it, keep it tidy.

Every code you open lands in the editor, in a tab of its own. This chapter covers what the editor shows and the tools that keep a code readable: folding, indentation, formatting, comments, and the chips next to its name.

  1. 01Tabs One tab per code, and how many can stay open.
  2. 02Reading a code Colours, line numbers, timeframe bands, the minimap.
  3. 03Folding and indentation Hide a block, let the editor indent for you.
  4. 04Format and comments Two shortcuts that rewrite spacing and comment marks.
  5. 05The chips in the header “unsaved”, “Studio Only”, “⏸ Paused”.
  6. 06In short What a copy carries, the shortcuts, common questions.
The editor with four codes open in tabs. The active code, 3 · Two timeframes at once, shows grey comment lines, coloured code, a pink band behind lines 40 to 42 and a small map of the whole code at the right edge. The status bar at the bottom reads chart linked, ProRealCode Script and All in sync.
The editor with four codes open. The minimap on the right edge and code folding are switched on here; both are off when Studio is new.
Before you startYou have run and saved a code once (chapter 02 · Your first indicator). Where the editor sits on your screen, and the rail of icons on its left, are covered in chapter 03 · A tour of the interface.
ProRealCode StudioUser guide · Chapter 06
01 · Tabs

One tab per code, six at a time unless you change it.

The tab strip: Fractal Box Indicator, (new), Guide – My first indicat… and the active tab 3 · Two timeframes at on…, each with a ×, then the + button.
The tab strip. The active tab is underlined; “+” at the end opens a new one. A long name is cut after 25 characters: hover the tab to read it whole.
  1. Open a code from the Codes window (chapter 07), or click “+” at the end of the strip.A new tab opens. A “+” tab is called “(new)” until its first Run, then takes the text of its first comment line.
  2. Click another tab to switch to it.Edits you had not run stay in the tab you left. Nothing is lost by switching.
  3. Click the × of a tab to close it.Only the tab closes. A code that is on the chart stays there. A code never saved and not on the chart would be lost, so Studio asks first.

What a tab can show

On the tabIt means
An amber dotThe tab holds edits the chart has not seen yet. “Run” applies them.
A hollow ringThe editor now holds a different code, and this tab's curves have stopped updating (see “⏸ Paused”, section 05).
×2, ×3…That many copies of the code are on the chart.

How many tabs

The counter at the right end of the strip, “4 / 6” here, reads open tabs against the limit. The button after it closes every tab at once, and asks only when a code would be lost.

The Maximum open codes setting set to 6, with its explanation: keeps the editor quick; at the limit, opening another code offers to close the oldest tab for you; codes saved in Codes are not affected.
⚙ Preferences → Limits. From 1 to 40; 6 when Studio is new.
At the limitOpening one code more than the limit asks to close a tab for you, and names it. Answer “Cancel” and nothing opens. Closing a tab never deletes a saved code: it stays in the Codes window.
ProRealCode StudioUser guide · Chapter 06
02 · Reading a code

Colours, line numbers and bands show where you are.

Lines 38 to 53 of the example 3 · Two timeframes at once: line numbers on the left, coloured code, a pink band behind lines 40 to 42, two grey comment lines, and line 52 running past the right edge. 1 2 3 4 5
The example “3 · Two timeframes at once”, which reads the RSI on the chart and on the daily timeframe.
  1. Line numbers. Error messages and the Problems panel refer to them (chapter 09).
  2. Comments, in grey. Studio does not run them.
  3. Colours. Instructions, numbers and text in quotes each have their own colour; the names you invent stay black.
  4. A timeframe band. Every line under TIMEFRAME(daily) runs on daily bars, down to the next TIMEFRAME. The tint shows it without scrolling back up; TIMEFRAME(default) ends it. Each timeframe has its own colour.
  5. Long lines are not wrapped. Line 52 goes on past the right edge: scroll sideways to read it.

At the edges

The minimap, at the right edge, is the whole code in miniature: drag its box to scroll. It is off at first: ⚙ Preferences → Editor → “Minimap”.

The status bar names the language, read from the code itself.

The right end of the status bar: ProRealCode Script, All in sync, and the shortcut hints.
The right end of the status bar.

Bigger or smaller text

“A−” and “A+”, in the header of the editor, change the size of the code by one pixel per click, from 9 to 24 pixels. Studio starts at 13 and remembers your choice in this browser.

ProRealCode StudioUser guide · Chapter 06
03 · Folding and indentation

Fold a block away. The editor keeps the indentation.

Lines 45 to 53 of the same code, in a larger font. Line 48, IF rsiChart CROSSES OVER rsiDaily THEN, has a chevron in the gutter and a grey pill reading ⋯ 1 line; the next line number is 50, then ENDIF. 1 2
The IF block of line 48, folded. The line numbers jump from 48 to 50: they always count the whole code.
  1. The chevron. It sits next to every IF, FOR, WHILE and FUNCTION. Click it to fold the block down to its first line, again to open it.
  2. The pill counts the hidden lines. Click it to open the block.
  1. Open ⚙ Preferences → Editor and switch on “Code folding”.Chevrons appear in the gutter. Folding is off when Studio is new.
  2. Type IF close > open THEN and press Enter.The new line starts one level further in; typing ENDIF pulls it back out. Same for FOR and NEXT, WHILE and WEND, FUNCTION and ENDFUNCTION, ELSE and ELSIF.

⚙ Preferences → Editor

SettingAt firstWhat it does
MinimapOffThe map of the code at the right edge.
Auto-indentOnStep 2 above. Off: Enter is a plain new line.
Indent guidesOnA faint vertical rule per level of indentation.
Timeframe bandsOnThe tint behind each TIMEFRAME section.
Format on saveOnRe-indents the code each time you save it (section 04).
ProRealCode StudioUser guide · Chapter 06
04 · Format and comments

One shortcut re-indents the code. Another turns lines into comments.

The top of the three-dot menu: Format document, Shift+Alt+F; Toggle // comment, Ctrl+/; Toggle /* */ comment, Shift+Alt+A.
The top of the “⋯” menu, in the editor's header, with each shortcut.
  1. Click “⋯”, then “Format document”, or press Shift + Alt + F.Each line moves to the depth of its block, four spaces per level. The status bar reads “formatted”, or “already formatted” if nothing moved.
  2. Read the status bar if it says “⚠ unbalanced blocks”.An IF lacks its ENDIF, or a NEXT closes nothing. Fix the block, then format again.

Before

IF close > open THEN
count = count + 1
  IF count > 3 THEN
      signal = 1
ENDIF
    ENDIF

After “Format document”

IF close > open THEN
    count = count + 1
    IF count > 3 THEN
        signal = 1
    ENDIF
ENDIF

Only the spaces at the start of each line change. Words, capitals and the inside of /* … */ comments stay as you wrote them, and folded blocks stay folded. With “Format on save” on, “Save” formats the code first; a code with unbalanced blocks is saved exactly as written instead.

Comment out a few lines

  1. Select the lines and press Ctrl + /.Each line starts with //, in one column. Press again to remove the marks. Ctrl + Z undoes a toggle, or a format, in one step.
  2. For a long passage, press Ctrl + Shift + / or Shift + Alt + A instead.One /* before the selection, one */ after it.
ProRealCode StudioUser guide · Chapter 06
05 · The chips in the header

Three kinds of chip say what state the code is in.

ChipIt meansWhat to do
unsaved
saved · to sync · synced
Where the code is kept. “unsaved”: the editor holds changes not saved yet. The other three are described in chapter 02.Ctrl + S to save.
Studio OnlyThe code uses at least one instruction that the ProRealTime platform's own editor cannot compile. It runs in Studio; pasted into ProRealTime, it would be refused.Hover the chip: it names the instructions.
⏸ PausedThis code is on the chart, but the editor now holds a different code: emptied, rewritten, or in another language. Its curves have stopped updating.Click the chip: it runs what is in the editor. Or undo back to the old code, and the curves resume on their own.
The tooltip of the Studio Only chip: This code is not compatible with official ProBuilder — input, alert.
Next to “ProRealCode Studio”, the code's name and its chips. Hover “Studio Only”: it lists up to four instructions, then “and N more”. Here, input and alert.

No chip is the good news. Code using only the instructions shared with the ProBuilder syntax is in ProBuilder Compatibility Mode. Nothing declares it: the editor marks the opposite case with a “Studio Only” badge.

“Studio Only” is not an error. It is a warning for the day you paste the code into the ProRealTime platform. What the language adds, instruction by instruction, is in chapter 23 · ProRealCode Script: what the language adds.

“Studio Only” on a code you did not change?Any code that declares a setting with input() carries it: settings are one of the additions. Chapter 08 · Variables and settings explains them.
ProRealCode StudioUser guide · Chapter 06
Chapter 06 · In short

Tabs to switch, tools to tidy, chips to read.

What a copy carries

Whatever you copy or cut out of the editor reaches the clipboard with one extra comment on its first line. It says the text comes from ProRealCode Studio, and from which version.

The ProRealTime platform and Studio both skip it, since it is a comment. Copying text that already starts with one does not add a second.

//@ProRealCodeScript@version=x.y.z@
ma = Average[20](close)
Shortcut, in the editorDoes
Ctrl + Enter · Ctrl + SRun · Save
Shift + Alt + FFormat document
Ctrl + /// at the start of each selected line, or off again
Shift + Alt + A/* … */ around the selection (also Ctrl + Shift + /)
Tab · Shift + TabMove the selected lines one level in, or out

I closed a tab. Is my code gone?

No, if it was saved: reopen it from “My codes” (chapter 07). A code on the chart stays there too. Studio asks before closing a code that was never saved and is not on the chart.

Where is the minimap?

Off at first. Switch it on in ⚙ Preferences → Editor → “Minimap”. Code folding sits in the same list.

“Save” moved my lines. Why?

“Format on save” is on: the code was re-indented before being saved. Only the spaces at the start of lines changed. Switch it off in ⚙ Preferences → Editor.

My curves stopped moving.

Look for “⏸ Paused” next to the code's name. The editor holds a different code from the one on the chart: click the chip to run it, or undo your change.

Next

Chapter 07 · Managing your codes

The Codes window: your codes and folders, favourites, import and export, the examples and the prorealcode.com library.

ProRealCode StudioUser guide · Chapter 06
ProRealCode ProRealCode
Loading...