NMFINTECHSTRATEGY LAB / 01App source code ↗
A SIMPLE IDEA. TWO MOVING AVERAGES.

Follow the crossover.

Explore a US stock with AlgoQuant’s SMA2 strategy. Choose your window, set two moving averages, and inspect what happened.

How the strategy works ↓

Your strategy, in perspective.

Run a backtest to see prices, moving averages, portfolio value, and every execution.

POWERED BY ALGOQUANT
UNDER THE HOOD

How the SMA2 strategy works

SMA2 is a trend-following strategy using two simple moving averages of the selected stock’s daily adjusted closing prices. An N-day SMA is the arithmetic mean of the last N trading-session closes. With 10 days vs 30 days, the fast average responds to price changes more quickly than the slow average.

1. Wait for a crossover

When the fast SMA crosses above the slow SMA, the target position becomes +1 share (long). When it crosses below, the target becomes −1 share (short). The strategy holds its position between crossovers; it does not place a new order every day. Equality alone produces no order; moving from equality to above or below can trigger one.

2. Trade on the next session

A crossover calculated from Monday’s close is executed at Tuesday’s adjusted close, or the next available trading session. The chart shows each day’s current averages, so a fill appears one session after its signal. This deliberate delay avoids filling at the same close used to discover the signal; it is not a next-open execution model.

3. Size orders to reach the target

The simulation starts flat with $10,000 cash. The first entry buys or sells one share. Reversing from +1 to −1 sells two shares; reversing from −1 to +1 buys two. Position size stays at one share in either direction, regardless of account size. Cash is mostly idle, so account returns can be small even when the stock moves substantially.

4. Warm up, then mark to market

Prices before the selected start date initialize the averages without making trades. Trading begins within the selected period only when a new crossover is detected; the strategy does not automatically enter merely because one average is already above the other. Start and end dates are inclusive, using available trading sessions. Final open positions remain valued at the last adjusted close rather than being forcibly closed.

5. Read the results with the model’s assumptions

Portfolio value equals cash plus signed share quantity × adjusted price. Profit/loss is final portfolio value minus $10,000; total return divides that profit/loss by $10,000. There are no trading fees, bid–ask spread, slippage, short-borrow charges, margin restrictions, or interest on cash. Adjusted prices incorporate corporate-action adjustments; dividends are not paid again as separate cash flows. There is no stop-loss or take-profit rule. Moving-average strategies can suffer repeated reversals in sideways markets.

The chart’s buy-and-hold comparison buys one share of the selected stock and leaves the remaining cash idle. SPY is a separate benchmark for CAPM and excess-return measures. Detailed measures state their sampling, units and assumptions; short histories or missing prerequisites can produce N/A.

Inspect and run the app

SMA2App.java — strategy and backtest implementation ↗

The public repository contains this app’s source. It uses the published AlgoQuant library. This educational simulation does not predict future performance.