Hands-on tutorials
Example 1: MACD Cross
Apply a template, read the wiring and verify a long-only entry and exit step by step.
What this example does
When flat, open a long on a MACD Line / Signal Line upward cross. Close the long on a downward cross. Keep one position at a time; do not add on every bar above the signal line. This is a local simulated learning exercise.
For input ports and fixed values, read “Left input port reference” and “Fixed value or strategy parameter?” in Build a visual strategy.
- View Rules opens a preview; it does not start trading.
- Use Template creates an editable copy in My Strategies. Keep separate copies for the two lessons.
Create and inspect the model
- Open Quant → Strategy Templates → MACD Cross → View Rules → Use Template. Name the copy “Lesson 1 · MACD Cross”.
- In My Strategies select this copy. Check Fast Length 12, Slow Length 26, Signal Length 9, Source Close, both MA types EMA and Histogram Mode Standard (1×).
- Follow Close → MACD Input Price. Send MACD Line to the left value and Signal Line to the right value of both Cross Above and Cross Below.
- Connect Cross Above → entry Trigger Condition; connect Cross Below → exit Trigger Condition. Click Check Strategy and save.
- Close feeds the MACD Input Price. Use the same instrument and timeframe throughout.
- MACD Line and Signal Line feed both cross nodes. Their order matters: MACD Line is the left value.
- The upward cross triggers entry; the downward cross triggers exit. Blue ports carry numbers; green ports carry conditions.
Read the same logic as rules
Open Condition Rules and compare the two sentences with the canvas. Check Trade Settings on the entry and exit: long-only, flat-position entry, full-position reduce-only exit. Keep the template’s 1 integer unit, 2% stop loss and 4% take profit for this exercise; allocate enough simulated capital for the chosen contract and fees.
- The upper rule opens or adds a position. Keep long-only and the flat-position entry guard for this lesson.
- The lower rule closes or reduces the existing long. It must not open a short.
- Trade Settings configures sizing and protection separately from the signal. Amounts in the screenshot are illustrative.
Choose data and run
- Open Backtest Replay → Replay Settings. Select “Lesson 1 · MACD Cross”, a local OHLCV dataset and a matching instrument/timeframe. The template screenshot uses 15m; choose your available dataset interval consistently in the model and replay.
- Select a simulated account and explicitly set the allocated capital, sizing and leverage. If replay uses equity-percentage sizing, review that budget instead of assuming the template’s fixed quantity will apply. Reserve money for fees.
- Review the 2%/4% protection and enter the provider fee percentage (for example, 0.1 means 0.1%). Save Settings, then Play.
- Pause at the first confirmed fill and use Next Bar to inspect the order, simulated position, price line and execution log together.
- Select the lesson strategy at the top, then a local dataset with matching symbol and interval.
- Account & Capital selects the simulated account and allocated budget; it does not select another strategy.
- Position Sizing & Leverage controls order size. An equity-percentage budget still has to afford at least one integer contract plus fees.
Decide whether a signal is correct
The numbers below are hand-written signal illustrations, not measured backtest returns. Warm-up values are not signals. A valid cross requests an action; an actual fill also requires a valid position state, available funds and the configured execution timing. A stop-loss or take-profit exit can happen without a MACD cross.
- Check the signal timestamp against the fill timestamp; a fill may be later than its confirmed signal.
- If orders are rejected, read the reason. Do not count an order request or a B marker alone as proof of a completed fill.
- Stop and Play starts a fresh execution. Use a manually selected saved run only when you intend to replay previous results.
| Previous → current bar | Condition | Expected action |
|---|---|---|
| MACD −1.2 / Signal −1.0 → MACD −0.8 / Signal −0.9 | Cross Above | If flat, request a long entry |
| MACD −0.8 / Signal −0.9 → MACD −0.6 / Signal −0.7 | Still above; no new cross | No new entry |
| MACD 1.2 / Signal 1.0 → MACD 0.8 / Signal 0.9 | Cross Below | If long, request a close |
For the current Desktop workflow. Labels and available capabilities can vary by application version and connected provider.