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 code that places orders is a strategy. Studio plays it over every bar the chart holds, marks each trade on the candles and puts the numbers in a window of their own. This chapter runs one, reads its results, and says what those results are worth.
BUY, SELL, SET STOP and the others, are listed in chapter 23. Here you use a four-line example.1IF NOT LongOnMarket AND close CROSSES OVER Average[20](close) THEN2 BUY 1 SHARES AT MARKET3ENDIF4SET STOP %LOSS 2
Line 1 asks two questions: no long position open yet, and the close crossing above its 20-bar average.
Line 2 buys one unit when both are true. Any of BUY, SELL, SELLSHORT or EXITSHORT makes a code a strategy.
Line 4 places a stop 2 % under the entry price of every position.
1
2
3
4
5
6
7
1
2
3
4
5
6
7
| Tile | What it says |
|---|---|
| Win rate, Win / Loss | The share of closed trades that made money, 26.7 % here, then the same split as a ring. |
| Profit factor | Money won divided by money lost. Under 1, the losers weigh more: 0.84 here. A dash when no trade lost. |
| Max drawdown | The worst fall of the equity from a high, in money and in percent of that high, with the date it bottomed. |
| Trade P&L | One bar per trade, up for a gain: the last 60 trades. |
| Trades | Closed trades, split long and short, plus any position still open. |
| Average trade | The mean result of a trade, with the best and the worst one. |
| Losing streak | The longest run of losing trades in a row, what it cost and when it ended. |
| In market | The share of bars spent holding a position: 1,429 of 2,981, or 48 %. |
The columns. SIDE and QTY: long or short, and the size. IN BAR, TIME and IN: the entry, as bar number, date and price. OUT BAR and OUT: the exit. P&L and EXIT: the result, and what closed the trade, “order” for an exit the code placed, “Stop” for its stop.
| Arrow | An entry, just outside the candle: green when the order bought, red when it sold. |
| Dot and sign | An exit: a small dot at the price it left at, and a sign for the reason. Take Profit and Stop Loss each have their own; any other close is a cross. |
| Caption | The order and its price, BUY 1.0852 for instance, on the 60 most recent orders. |
| Dotted line | From entry to exit: green for a gain, red for a loss, grey for exactly nothing. The 400 most recent trades are drawn. |
| Setting | At first | Effect |
|---|---|---|
| Initial capital | 10000 | The starting balance. Percentages, net and drawdown, are measured against it. |
| Lot size | 1 | What one LOT means: BUY 2 LOTS opens 2 × this many units. Leave it at 1 unless you trade forex, where a standard lot is usually 100 000. |
| Use the current spread | on | Each fill pays half the instrument's current spread: a buy at the ask, a sell at the bid. Off, fills are at the bar price. |
| Order labels on the chart | on | The captions of task 5. The arrows stay either way. |
| Trade lines on the chart | on | The dotted lines of task 5. |
A code with BUY, SELL, SELLSHORT or EXITSHORT is a strategy. Studio runs it over the chart's history, fills each order at the next candle's open, and keeps every run of the session in the results window, where the tiles, the list of trades and the marks on the chart all describe the same trades.
No. Count the trades. On forex, one unit per trade earns fractions of a unit: set the lot size, or buy more units in the code.
The two backtests do not settle a bar in the same way when a stop and a target meet in it, and the spread may differ. Compare the trades, not only the total.
Runs last as long as the ProRealTime tab. A reload clears them. Note the figures you want to keep.
Open a run from the Strategies window, with the chart icon of a strategy, or click a row of “Completed runs”.
No. The code decides at the close; the order fills at the next open. Between the two, the price moved.
Yes. Click “Period” in the results window and set “From” and “To”, for this strategy only.
No investment advice. A backtest describes what a code would have done on past prices, under the assumptions listed in this chapter. It is not a forecast, not investment advice and not a recommendation to buy or sell anything. Past results do not predict future results.
Chapter 19 · Strategies in real time