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 10 · Part II — Writing code

See how a code works, card by card.

A code you did not write, or wrote a year ago, is hard to read line by line. The flow map draws it instead: one card per value, setting or calculation, and an arrow from each value to what is computed from it, up to what reaches the chart.

  1. 01Open the map From the ⋯ menu of the editor.
  2. 02Read the cards Seven kinds, one colour each.
  3. 03Trace a card What feeds it, what it feeds, its code.
  4. 04The toolbar, the search, the keys Find a step, zoom, move.
The window How this code works on the example Trend heat ribbon + regime HUD: a toolbar, a legend of card colours and connection lines, then columns of cards joined by arrows, a minimap at the bottom right and zoom buttons under it.
The map of the bundled example “Trend heat ribbon + regime HUD”: 48 cards on screen, the minimap bottom right.
Before you startThe map reads ProRealCode Script, the code of the tab in front, and only a code without errors (chapter 09). It changes nothing in your code: it is a view.
ProRealCode StudioUser guide · Chapter 10
01 · Open the map

Two clicks from the editor, and the code becomes a map.

  1. Bring the code to the front of the editor.The map reads the tab you are looking at.
  2. Click ⋯ at the top right of the editor, then “Dataflow map”.The window “How this code works” covers the screen, the code's name beside the title.
  3. To leave, click “Close” at the top right, or press Esc.You are back in the editor, where you left it.
The ⋯ menu of the editor: Format document, Toggle // comment, Toggle /* */ comment, Dataflow map, Dashboard, Dock: bottom, Fullscreen, Re-detect chart.
The ⋯ menu. “Dataflow map” is the fourth row.
The top left of the map window: the title How this code works with the chip Trend heat ribbon + regime HUD, the line 48 steps of 62, the rest folded, feeding 3 chart outputs, the search field with 48 of 62 shown, and the legend of card colours. 1 2 3 4
The top left of the window, above the map itself.
  1. The title and the code's name. Check it is the code you meant.
  2. The count. Here “48 steps of 62, the rest folded, feeding 3 chart outputs”: 62 cards in all, 48 on screen, 3 things drawn on the chart.
  3. The search, by name or by line number, and how many cards are on screen (sheet 5).
  4. The legend: the colour of each kind of card (sheet 3). The toolbar and the kinds of connection are to its right (sheets 4 and 5).
ProRealCode StudioUser guide · Chapter 10
02 · Read the cards

Each card is one thing the code reads, computes or draws.

A part of the map: purple SETTING cards and a blue LIVE PRICE card Close price on the left, orange STEP cards Ribbon ema, green VALUE cards E2 to E5, and black ON CHART cards Line: Ribbon mid and Line: Slow, joined by arrows.
A detail of the same map. Each card: its kind on top, its name in bold, the name used in the code underneath.

Every arrow goes from a value to what is computed from it. Follow them from the left, where the code reads prices and settings, towards the black cards, which are what you see on the chart. When a comment sits just above a line of your code, the card shows that comment as its explanation.

CardWhat it stands for
Live priceA price the code reads: the close, the high… Its panel says “A raw market read.”
SettingA value you can change in ⚙ Settings (chapter 08).
SwitchA setting that turns a part of the code on or off: “A setting that changes which branch runs below.”
StepA calculation: an average, an RSI, a colour, a table cell.
ValueA variable of the code. Its panel says what it is computed from, and on which line.
State machineSeveral variables that feed each other from one bar to the next.
On chartA curve, a fill or a drawing that reaches the chart.
ProRealCode StudioUser guide · Chapter 10
03 · Trace a card

Click a card: what feeds it lights up, and so does what it feeds.

SETTINGRibbon opacity 0-255
fillAlpha
×

A setting — a constant for the whole run, editable from Inputs.

› Show code (line 34)
› Open in the editor⌖ Focus on this card
Illustration. The panel of the first card of the map, “Ribbon opacity 0-255”.
  1. Click a card.The cards that feed it and the cards it feeds stay lit, the rest fades. Dots run along its arrows. Its panel opens.
  2. Click “Show code” in the panel.The lines behind the card unfold under it.
  3. Click “Focus on this card”.The map keeps only the lit cards. Press Esc to get the whole map back.
  4. Click “Open in the editor”.The map closes and the editor shows that line.

The connections

The lineWhat it says
feeds into, solidThe value is used, on the same bar, to compute the next card.
from an earlier bar, dashedThe next card uses the value of a previous bar.
set by a setting, dottedA setting gives the next card its number, a period for instance.
only on a condition, amber dotsThe value only passes when an IF or FOR test lets it. Hidden until you press “Show conditions”.
drawn on chart, thickThe last link, into a card that reaches the chart.
↺ remembers its last barOn a card: the value starts from its own previous value.
ProRealCode StudioUser guide · Chapter 10
04 · The toolbar, the search, the keys

Ask for a line number, and the map shows its card.

ButtonWhat it does
Flows left to rightLays the cards out in columns. The default.
Flows top to bottomLays them out in rows.
Show conditionsAdds the connections that only carry a value when an IF or FOR test passes. Hidden by default: there can be three times as many as the others.
Show timingsMeasures the code and puts on each card its share of the time (chapter 11).
AnimateThe dots that run along a traced card's arrows. On by default; the map reads the same without them.
Show fewer cardsFolds repeated drawing calls into one card and skips small helpers such as round or abs. No connection is lost. On by itself above 40 cards.
Full codeOpens the whole code in a panel on the right.

Find a card

  1. Type a line number in “Find a step, or a line number”.The cards built from that line stand out. The counter reads, for instance, “2 of 48 match”.
  2. Or type part of a name, “ema” for instance.Capitals do not count.
  3. Press Esc to clear the search.

Move around

Scroll · dragMove
Ctrl + scrollZoom
+ −Zoom in, out
Arrow keysMove; with Shift, farther
FFit the whole map
0Reset the view

The three buttons bottom right do the same with the mouse. From 25 cards, a minimap sits above them: drag its box to move.

ProRealCode StudioUser guide · Chapter 10
Chapter 10 · In short

Open it, click a card, follow the arrows.

⋯ › “Dataflow map” opens the map of the code in front. Cards are what the code reads, computes and draws; arrows go from each value to what uses it. One click on a card lights its whole chain and opens its panel, with the code behind it one more click away. When you need the line itself, “Open in the editor” takes you there.

The map says “Fix the code errors first”.

The map is drawn from a code that runs. Correct the errors listed in Problems (chapter 09), then open it again.

It says “The dataflow map does not read code that declares //@version”.

The map reads ProRealCode Script only. A code that starts with //@version= has no map.

The count says 48 of 62. Where are the others?

Folded by “Show fewer cards”, which switches on by itself above 40 cards. Switch it off to see every card.

A card I expected is not there.

Type its line number in the search. A comment, a blank line or a closing word such as ENDIF has no card of its own.

Can I change the code from the map?

No. The map is a view. “Open in the editor” brings you to the line to change.

The dots are distracting.

Switch “Animate” off. Nothing else changes.

Next

Chapter 11 · Code performance

How long each code takes, and which of its lines takes the most.

ProRealCode StudioUser guide · Chapter 10
ProRealCode ProRealCode
Loading...