Strategy Tester

This manual explains how to back-test a strategy using JForex4's Strategy Tester, covering setup, testing methods, order execution logic, and how to read the results.


1. Open the Strategy Tester

  1. Go to View in the top menu bar and select Strategy Tester.
  2. The tester opens as a new tab alongside Orders, Positions, and Messages.
  3. Select your strategy from the drop-down menu. If it hasn't been added to the workspace yet, click Open to add it first.
  4. (Optional) Click Edit to open the strategy's source code in the Code Editor — available only if the .java source file is present.

2. Configure the Test

Account Settings

Click Account to define the simulated trading account:

  • Initial deposit and account currency
  • Leverage
  • Margin cut level (as % of used leverage)
  • Equity stop loss (MC Equity) — automatically halts the test if equity falls below this level

Instruments

Click Instruments to select which instruments historical data should be downloaded for. Select every instrument the strategy uses for trading or calculations.

Note: This is not where you choose the instrument the strategy actually trades — that's set separately, either hard-coded in the strategy or chosen later in the Define Parameters window.

Sample Period & Time Frame

Choose the historical date range (Sample Period) and the Time Frame:

  • Ticks — uses real historical tick data (most accurate, slowest).
  • Candles (1 Minute / 1 Hour / 1 Day) — faster, uses interpolation to generate ticks from OHLC candle data. Also lets you pick Bid or Ask as the base.

Visual Mode

Enable Visual Mode to watch the simulation play out on a live chart as it runs. When enabled, the Start button also unlocks playback controls to pause the test or slow down its speed.

Optimization

If your strategy has configurable parameters, enable Optimization to test multiple parameter combinations in a single run. For each parameter (other than instrument and period) you can define a minimum value, a step size, and a maximum value — the strategy is then tested once per step combination.

Results for each combination appear in the lower part of the tester window. Right-click any row to cancel it, copy its settings, view its report, or reuse its input parameters.

Profit Factor = Gross Profit ÷ Gross Loss (both taken as positive numbers). E.g., Gross Profit 1000 and Gross Loss 250 → Profit Factor = 4.0. It is always a positive value, and higher generally indicates a more favorable ratio of winning to losing trades.


3. Tick Filters (Ticks time frame only)

When Ticks is selected as the time frame, choose how ticks are filtered:

Filter Behavior
Process all ticks Most precise, but slowest — replays every tick ever recorded.
Process all ticks with a different non-recurrent price Skips ticks that repeat the same price.
Process ticks on a market direction Skips ticks unless they represent a genuine reversal/turning point in price direction.
Process ticks on a predefined price range change Skips ticks until price moves by a defined range.
Process ticks with the specified time interval Skips ticks based on a defined time interval.

4. Interpolation Methods (Candle time frames only)

Available when the time frame is a candle period (1 Min, 1 Hour, 1 Day). Instead of downloading real tick data, the tester generates synthetic ticks from the OHLC candle data — which speeds up testing significantly.

Method Description
Cubic Spline The most precise candle-based method. Builds ticks using OHLC prices as base points via cubic spline interpolation. Can occasionally generate more ticks than a real feed would produce for very short periods (e.g., 10 Sec).
4 ticks at OHLC The most reliable interpolation method among those available. Interpolates each candle into exactly 4 price ticks — Open, High, Low, and Close. The order of the High and Low ticks depends on which is closer to the Open price: whichever is nearer to Open is processed as the second tick, ahead of the other.
Tick on Open Generates a single tick using the candle's Open price.
Tick on Close Generates a single tick using the candle's Close price.

Example: if your strategy trades on 1-Minute candles and doesn't need finer granularity, select 1 Min as the time frame and 4 ticks at OHLC as the interpolation method — the strategy will then receive exactly 4 ticks per minute (open, then high/low in proximity order, then close).

5. Custom Settings

  • Save interpolated price data — keep or discard the generated tick data from interpolation.
  • Visual Mode: show/hide Equity, Balance, and P/L; choose a saved chart Template; set the default Period shown during Visual Mode.
  • Messages: enable Save Messages to a file; enable Save Reports to a file; enable Show Reports to automatically open the report after the test finishes.

6. Order Processing Logic

Understanding exactly how the tester fills orders is essential for trusting your backtest results.

General rule: Orders are executed at the order's own price — except when there is a market gap (e.g., the market reopens with a gap after a break). In gap situations:

  • LIMIT orders are filled at a better price than the order price.
  • STOP orders without a MAX.SLIPPAGE setting are filled at the first available price after the gap.
  • STOP orders with a MAX.SLIPPAGE setting, if the execution price would fall outside that slippage limit, are automatically resubmitted as LIMIT orders instead.

Detailed fill logic:

  • Orders triggered on the BID side are compared against interpolated BID candle prices; orders triggered on the ASK side are compared against interpolated ASK candle prices.
  • If an order (regardless of type) is triggered by a CLOSE, HIGH, or LOW price tick, it is filled at the order's own price, adjusted by the last known spread if necessary (this adjustment applies when the trigger comes from the opposite side).
  • If an order is triggered by an OPEN price tick, it is filled at that OPEN price tick on the corresponding side — except for a STOP order with MAX.SLIPPAGE set: if the OPEN tick falls outside the STOP's slippage limit, the order is converted to a LIMIT order instead.

Tip: Because "4 ticks at OHLC" always includes an Open tick per candle, this OPEN-triggered logic (and its STOP/MAX.SLIPPAGE exception) applies directly whenever you test with that interpolation method.

7. Run the Test

  1. Click the Start button.
  2. The Define Parameters window opens — set the strategy's configurable values here (instrument, amount, slippage, stop loss/take profit, etc.). The exact fields shown depend on your strategy's code.
  3. Click Run to begin the simulation.
  4. If Visual Mode is on, use the playback controls to pause or slow down the test as it runs.
  5. Once finished (large tick-based tests can take a while), the testing report opens automatically in your browser (if Show Reports is enabled).

8. Review the Results

The report includes trade-by-trade results, equity/balance curves, and summary statistics such as the Profit Factor described above. If you ran an Optimization sweep, compare the reports for each parameter combination from the results list at the bottom of the tester window before picking a configuration to move forward with.


Best Practices

  • Start with Ticks / "Process all ticks" for your final validation pass — it's the closest simulation to real market conditions, even though it's the slowest.
  • Use candle interpolation for quick iteration. While developing or tuning a strategy, "4 ticks at OHLC" gives fast, reliable feedback without downloading full tick history.
  • Match your interpolation/tick-filter choice to your strategy's logic. A strategy that reacts to OPEN prices behaves differently under "4 ticks at OHLC" than under "Tick on Close" — be sure your test method matches what triggers your strategy's real-world logic.
  • Watch for MAX.SLIPPAGE interactions. If your strategy relies on STOP orders, test both with and without MAX.SLIPPAGE to understand how gap and OPEN-tick scenarios could convert your orders to LIMIT fills.
  • Remember: past performance shown in the tester is not a reliable indicator of future performance — always validate further in a demo environment before going live.
The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.