Explore more topics
NexusTrade guide

Build and backtest ETH Bollinger mean reversion

Buy below the 20-day lower band and close when price returns to its 20-day average.

As of 2026-10-10

Jump to a section

TL;DR

The ETH mean reversion example lost 9.42% in 2024, with $837.50 in fees on $10,000 of starting capital. It buys below the lower 20 day Bollinger band and sells when price returns to its 20 day average, allocating 95% of buying power per entry. Reported maximum drawdown was 28.52%; the exported snapshots show 28.28%. SPY and Bitcoin reference curves rose during the same year. Inspect the fills and remaining holdings before changing one rule and testing separate dates.

Follow the example

Step 1 of 3

Read this pair's entry and exit

Read this pair’s entry condition, purchase amount and exit in the saved rules below.

Entry
Saved rule: Price < BollingerBand(20, Day, -2) AND position value = 0
Exit
Saved rule: Price >= SMA(20, Day) AND position value > 0
Allocation
Saved rule: 95% of buying power per entry; sell 100% of held units on exit
Pair
Saved rule: ETH-USD
What you should see

The plain-language purpose matches the saved rules below. Keep the rule, purchase size and exit together when creating your version.

ETH Bollinger mean reversion: completed 2024 backtest with SPY and BTC buy and hold25.3K7.7K2024-01-012024-12-31
ETH Bollinger mean reversion 2024-12-31, 21:00:00 UTC
9,058.18
SPY buy and hold 2024-12-31, 21:00:00 UTC
12,530.29
BTC buy and hold 2024-12-31, 21:00:00 UTC
21,926.92
ETH Bollinger mean reversionSPY buy and holdBTC buy and holdHistorical simulation
Completed 2024 historical simulation. The plotted observations and comparison series are preserved.
Step 2 of 3

Completed 2024 backtest

Explore the completed 2024 simulation below. Compare its recorded return and drawdown with the plotted benchmarks, then follow the captured fills. The original history, fees and execution assumptions remain available below.

What you should see

The exact stored history shown here, with its source's period, comparisons and limits. Opening the walkthrough does not rerun it.

Preview this strategy in Aurora: authored process map
Authored task map. It describes what to inspect; it is not an account screenshot or a measured result.
Step 3 of 3

Preview this strategy in Aurora

Review the provided strategy request without changing its pair or sizing. Ask for a draft preview before any saved candidate or paid test.

What you should see

An inspectable candidate. New dates or a changed rule define another experiment, not the published result.

Choose a step to follow the example. Opening a request lets you review it; it does not submit a job or change your account.

Inspect the recorded trades

  1. Apr 12, 2024

    Pair

    ETH-USD

    Side

    Buy

    Units (rounded)

    2.96195593

    Submitted price

    $3207.34

    Filled price

    $3207.34

    Fee

    $66.50

  2. Apr 27, 2024

    Pair

    ETH-USD

    Side

    Sell

    Units (rounded)

    2.94122224

    Submitted price

    $3240.80

    Filled price

    $3240.80

    Fee

    $66.72

  3. Apr 28, 2024

    Pair

    ETH-USD

    Side

    Sell

    Units (rounded)

    0.02073369

    Submitted price

    $3305.35

    Filled price

    $3305.35

    Fee

    $0.48

  4. May 01, 2024

    Pair

    ETH-USD

    Side

    Buy

    Units (rounded)

    3.26855132

    Submitted price

    $2896.82

    Filled price

    $2896.82

    Fee

    $66.28

  5. May 04, 2024

    Pair

    ETH-USD

    Side

    Sell

    Units (rounded)

    3.24567146

    Submitted price

    $3133.46

    Filled price

    $3133.46

    Fee

    $71.19

  6. May 04, 2024

    Pair

    ETH-USD

    Side

    Sell

    Units (rounded)

    0.02271970

    Submitted price

    $3138.92

    Filled price

    $3138.92

    Fee

    $0.50

  7. May 05, 2024

    Pair

    ETH-USD

    Side

    Sell

    Units (rounded)

    0.00016016

    Submitted price

    $3145.66

    Filled price

    $3145.66

    Fee

    $0.00

  8. Jun 11, 2024

    Pair

    ETH-USD

    Side

    Buy

    Units (rounded)

    2.84841349

    Submitted price

    $3536.09

    Filled price

    $3536.09

    Fee

    $70.51

Recorded rows in source order; spacing does not represent elapsed time.

Show the table · 8 rows, 7 columns

Scroll sideways to compare all columns. Select a heading to sort.

Apr 12, 2024ETH-USDBuy2.96195593$3207.34$3207.34$66.50
Apr 27, 2024ETH-USDSell2.94122224$3240.80$3240.80$66.72
Apr 28, 2024ETH-USDSell0.02073369$3305.35$3305.35$0.48
May 01, 2024ETH-USDBuy3.26855132$2896.82$2896.82$66.28
May 04, 2024ETH-USDSell3.24567146$3133.46$3133.46$71.19
May 04, 2024ETH-USDSell0.02271970$3138.92$3138.92$0.50
May 05, 2024ETH-USDSell0.00016016$3145.66$3145.66$0.00
Jun 11, 2024ETH-USDBuy2.84841349$3536.09$3536.09$70.51

Follow the Filled events by pair, side and time. Compare the submitted price, filled price, fractional quantity and fee. This table shows up to eight orders from the captured excerpt (20 Filled events).

For a percentage fee, multiply the traded notional by 0.007. To follow a position, start with a purchase and inspect subsequent sale quantities, remaining holdings and cash flows. For the weekly accumulation example, follow each purchase and the resulting position value.

The algorithm

  1. Entry

    Price < BollingerBand(20, Day, -2) AND position value = 0

  2. Exit

    Price >= SMA(20, Day) AND position value > 0

  3. Allocation

    95% of buying power per entry; sell 100% of held units on exit

  4. Pair

    ETH-USD

  5. Execution

    Market; fractional units enabled

  6. Starting capital

    $10,000; no additional deposits

Show the table · 6 rows, 2 columns
DecisionSaved rule
EntryPrice < BollingerBand(20, Day, -2) AND position value = 0
ExitPrice >= SMA(20, Day) AND position value > 0
Allocation95% of buying power per entry; sell 100% of held units on exit
PairETH-USD
ExecutionMarket; fractional units enabled
Starting capital$10,000; no additional deposits

This example trades ETH-USD as a spot Cryptocurrency asset. The saved rules were read back and verified with automated trading off.

Create the same strategy

Ask Aurora to build the rules above, review the preview, then save the draft with automated trading off. Confirm the Cryptocurrency pair, allocation and entry and exit conditions in the saved rules.

In the native Strategies editor, use Buy and Sell actions with the same Cryptocurrency pair. Add the indicator and position-value conditions shown above. The weekly accumulation example uses a single Buy rule with a seven-day DaysSinceOrder condition.

Plan a separate variant and later test

Review the optional next experiment

After reviewing the recorded example, use the prepared request above for the original rules. This optional plan covers a separate variant and a later test.

  1. Create one variant, then test unseen dates

    Ask: "Change only the entry allocation from 95% to 75% of buying power. Show the rule diff and compare both candidates on the 2024 development period with every other setting fixed." After choosing, freeze the rules and select another test period you have not inspected. The displayed 2024 results already make 2024 a viewed development period. Keep any later revisions in a new research cycle.

Create and backtest with Python

Use the Python SDK instead of Aurora

Python SDK 1.42.0. Save the runner below as run_eth_bollinger_reversion.py.

Install and download

Shell
python3 -m pip install nexustrade==1.42.0
export NEXUSTRADE_API_KEY="YOUR_API_KEY"
curl --fail --output eth_bollinger_reversion.py https://nexustrade.io/seo/strategy-examples/eth-bollinger-reversion.py

Create, test and inspect

Python
from eth_bollinger_reversion import create_eth_bollinger_reversion, backtest_eth_bollinger_reversion

book = create_eth_bollinger_reversion()
completed = backtest_eth_bollinger_reversion()
print(completed["result"])

Run

Shell
python3 run_eth_bollinger_reversion.py

Python strategy and backtest functions

View complete Python SDK functions

The backtest function submits the 2024 test with SPY as its benchmark, records events and waits for the result. Use a new request key when changing rules, dates or fees.

Python
import nexustrade as nt


def create_eth_bollinger_reversion():
    asset = nt.crypto_asset("ETH-USD")
    return nt.portfolio(
        "Public SEO crypto example - ETH Bollinger mean reversion",
        [
            nt.strategy(
                "Enter ETH Bollinger mean reversion",
                ((nt.Price(asset) < nt.BollingerBand(asset, 20, "Day", -2)) & (nt.PositionValue(asset) == nt.Value(0))),
                nt.buy(asset, 95, "percent of buying power")
            ),
            nt.strategy(
                "Exit ETH Bollinger mean reversion",
                ((nt.Price(asset) >= nt.SMA(asset, 20, "Day")) & (nt.PositionValue(asset) > nt.Value(0))),
                nt.sell(asset, 100, "percent of current positions")
            ),
        ],
        initial_value=10000,
        supports_crypto=True,
        supports_fractional_shares=True,
        alerts_enabled=False,
        dividend_policy='cash',
    )


def backtest_eth_bollinger_reversion(client=None):
    client = client or nt.NexusTradeClient.from_environment()
    operation = client.create_backtest(
        nt.backtest(
            create_eth_bollinger_reversion(),
            start_date="2024-01-01", end_date="2024-12-31",
            interval="Day", baseline_symbol="SPY",
            initial_value=10000, generate_events=True,
            dividend_policy="cash",
            fee_config={"Stock": {"type": "percent", "amount": 0.1},
                        "Cryptocurrency": {"type": "percent", "amount": 0.7},
                        "Option": {"type": "dollars", "amount": 0.65}},
        ),
        idempotency_key="explore-eth-bollinger-reversion-2024-spy-v1",
    )
    return client.wait_for_backtest(operation["id"])


# Build locally: book = create_eth_bollinger_reversion()
# Run and inspect: completed = backtest_eth_bollinger_reversion(); print(completed["result"])

Create and backtest with TypeScript

Use the TypeScript SDK instead of Aurora

TypeScript SDK 1.42.0. Save the runner below as run-eth-bollinger-reversion.ts.

Install and download

Shell
npm install nexustrade@1.42.0
npm install --save-dev tsx
export NEXUSTRADE_API_KEY="YOUR_API_KEY"
curl --fail --output eth-bollinger-reversion.ts https://nexustrade.io/seo/strategy-examples/eth-bollinger-reversion.ts

Create, test and inspect

TypeScript
import { createEthBollingerReversion, backtestEthBollingerReversion } from "./eth-bollinger-reversion";

async function main() {
  const book = createEthBollingerReversion();
  const completed = await backtestEthBollingerReversion();
  console.log(completed.result);
}

main().catch((error: unknown) => {
  console.error(error);
  process.exitCode = 1;
});

Run

Shell
npx tsx run-eth-bollinger-reversion.ts

TypeScript strategy and backtest functions

View complete TypeScript SDK functions

The same rules, dates and fees are used in both SDKs. The backtest function keeps its request key across retries.

TypeScript
import * as nt from "nexustrade";

export function createEthBollingerReversion() {
  const asset = nt.cryptoAsset("ETH-USD");
  return nt.portfolio(
    "Public SEO crypto example - ETH Bollinger mean reversion",
    [
      nt.strategy(
          "Enter ETH Bollinger mean reversion",
          nt.and(
              nt.lt(nt.Price(asset), nt.BollingerBand(asset, 20, "Day", -2)),
              nt.eq(nt.PositionValue(asset), nt.Value(0))
          ),
          nt.buy(asset, 95, "percent of buying power")
      ),
      nt.strategy(
          "Exit ETH Bollinger mean reversion",
          nt.and(
              nt.gte(nt.Price(asset), nt.SMA(asset, 20, "Day")),
              nt.gt(nt.PositionValue(asset), nt.Value(0))
          ),
          nt.sell(asset, 100, "percent of current positions")
      ),
    ],
    { initialValue: 10000, supportsCrypto: true, supportsFractionalShares: true, alertsEnabled: false, dividendPolicy: "cash" }
  );
}

export async function backtestEthBollingerReversion(client = new nt.NexusTradeClient()) {
  const operation = await client.createBacktest(
    nt.backtest(createEthBollingerReversion(), {
      startDate: "2024-01-01", endDate: "2024-12-31",
      interval: "Day", baselineSymbol: "SPY",
      initialValue: 10000, generateEvents: true,
      dividendPolicy: "cash",
      feeConfig: {
        Stock: { type: "percent", amount: 0.1 },
        Cryptocurrency: { type: "percent", amount: 0.7 },
        Option: { type: "dollars", amount: 0.65 },
      },
    }),
    { idempotencyKey: "explore-eth-bollinger-reversion-2024-spy-v1" }
  );
  if (typeof operation.id !== "string") throw new Error("Missing backtest ID");
  return client.waitForBacktest(operation.id);
}

// Build locally: const book = createEthBollingerReversion();
// Run and inspect: const completed = await backtestEthBollingerReversion(); console.log(completed.result);

Completed 2024 backtest

ETH Bollinger mean reversion: completed 2024 backtest with SPY and BTC buy and hold25.3K7.7K2024-01-012024-12-31
ETH Bollinger mean reversion 2024-12-31, 21:00:00 UTC
9,058.18
SPY buy and hold 2024-12-31, 21:00:00 UTC
12,530.29
BTC buy and hold 2024-12-31, 21:00:00 UTC
21,926.92
ETH Bollinger mean reversionSPY buy and holdBTC buy and holdHistorical simulation
Show the table · 11 rows, 2 columns

Scroll sideways to compare all columns. Select a heading to sort.

StatusCOMPLETE
Backtest return-9.42%
Reported maximum drawdown28.52%
SPY buy-and-hold return25.30%
BTC buy-and-hold return119.27%
Total recorded trading fees$837.50
Engine closed-trade count13
Starting capital$10000.00
Ending portfolio value$9058.18
Ending cash$397.69
Ending position value$8660.49

This saved algorithm completed a Day backtest from 2024-01-01 through 2024-12-31, with $10000.00 starting capital. The chart includes all 744 exported history points.

Compare the strategy with SPY and BTC buy and hold. Each benchmark invests the full $10000.00 starting balance over the same 2024 period. SPY follows its trading sessions; BTC includes weekends. This algorithm follows its own allocation and entry/exit rules, with 0.7% of traded notional charged on each fill. Explore cash and position values to see how capital was deployed.

Understand this entry with Aurora

  1. ETH-USD price < ETH-USD 20 day BollingerBand

    Left value3,366.02<Right value3,513.2366ResultTrue
  2. ETH-USD position value = constant

    Left value0=Right value0ResultTrue
Show the table · 2 rows, 5 columns

Scroll sideways to compare all columns. Select a heading to sort.

ETH-USD price < ETH-USD 20 day BollingerBand3,366.02<3,513.2366True
ETH-USD position value = constant0=0True

At 2024-12-19T21:00:00.000Z, the recorded rule was: ETH-USD last price < 20 Day ETH-USD Bollinger Band and Position market value (ETH-USD) = Constant 0. Its overall result was true. Read the individual comparisons below, then ask Aurora to explain how they led to the action.

The signal requested 95 percent of buying power at a submitted price of 3,366.02. 1 captured Filled order shares this timestamp; Aurora receives those fields with the signal.

Inspect the original signal record

View captured signal JSON
JSON
{
  "eventType": "BuySignal",
  "event": {
    "eventType": "BuySignal",
    "timestamp": "2024-12-19T21:00:00.000Z",
    "signals": [
      {
        "conditionName": "ETH-USD last price < 20 Day ETH-USD Bollinger Band and Position market value (ETH-USD) = Constant 0",
        "audit": {
          "type": "minimal",
          "results": {
            "0.0": {
              "isTrue": true,
              "lhsValue": 3366.02001953125,
              "rhsValue": 3513.2366040393435,
              "lhsError": null,
              "rhsError": null,
              "comparison": "lessThan"
            },
            "0.1": {
              "isTrue": true,
              "lhsValue": 0,
              "rhsValue": 0,
              "lhsError": null,
              "rhsError": null,
              "comparison": "equal"
            }
          },
          "failuresOnly": false
        },
        "isTrue": true,
        "actionName": "Buy",
        "actionMetadata": {
          "buyOrSell": {
            "targetAsset": {
              "name": "ETH-USD",
              "symbol": "ETH-USD",
              "type": "Cryptocurrency",
              "underlyingSymbol": null,
              "optionType": null,
              "expirationDate": null,
              "strikePrice": null,
              "multiplier": null
            },
            "allocation": {
              "type": "percent of buying power",
              "amount": 95
            },
            "price": 3366.02001953125,
            "orderType": "Market Order"
          }
        },
        "orderExecution": {
          "type": "Market"
        }
      }
    ]
  },
  "timestamp": 1734642000000
}

Explore a drawdown period

Scale: 0 to 10.7K USD · zero baseline

Portfolio value

  • 2024-06-16T20:00:00.000Z$10704.02
  • 2024-08-05T13:30:00.000Z$7677.45

Scale: 0 to 459.61 USD · zero baseline

Cash

  • 2024-06-16T20:00:00.000Z$459.61
  • 2024-08-05T13:30:00.000Z$445.70

Scale: 0 to 10.24K USD · zero baseline

Position value

  • 2024-06-16T20:00:00.000Z$10244.40
  • 2024-08-05T13:30:00.000Z$7231.75
Show the table · 2 rows, 4 columns

Scroll sideways to compare all columns. Select a heading to sort.

2024-06-16T20:00:00.000Z$10704.02$459.61$10244.40
2024-08-05T13:30:00.000Z$7677.45$445.70$7231.75

Follow the decline from Jun 16, 2024 to Aug 05, 2024. The table retains the recorded portfolio, cash and position values. The engine reported maximum drawdown of 28.52%.

Test another version

Change one rule or choose a different date range, then compare the resulting curve and trade events with this saved experiment. Explore which trades, fees and periods explain the difference.

Exact captured fill fields

  1. 2024-04-12T20:00:00.000Z

    Pair

    ETH-USD

    Side

    Buy

    Units

    2.961955932227903

    Submitted price

    $3207.34

    Filled price

    $3207.34

    Fee

    $66.50

  2. 2024-04-27T20:00:00.000Z

    Pair

    ETH-USD

    Side

    Sell

    Units

    2.9412222407023076

    Submitted price

    $3240.80

    Filled price

    $3240.80

    Fee

    $66.72

  3. 2024-04-28T13:30:00.000Z

    Pair

    ETH-USD

    Side

    Sell

    Units

    0.020733691525595344

    Submitted price

    $3305.35

    Filled price

    $3305.35

    Fee

    $0.48

  4. 2024-05-01T13:30:00.000Z

    Pair

    ETH-USD

    Side

    Buy

    Units

    3.2685513222924385

    Submitted price

    $2896.82

    Filled price

    $2896.82

    Fee

    $66.28

  5. 2024-05-04T13:30:00.000Z

    Pair

    ETH-USD

    Side

    Sell

    Units

    3.245671463036391

    Submitted price

    $3133.46

    Filled price

    $3133.46

    Fee

    $71.19

  6. 2024-05-04T20:00:00.000Z

    Pair

    ETH-USD

    Side

    Sell

    Units

    0.022719700241254966

    Submitted price

    $3138.92

    Filled price

    $3138.92

    Fee

    $0.50

  7. 2024-05-05T13:30:00.000Z

    Pair

    ETH-USD

    Side

    Sell

    Units

    0.00016015901479233055

    Submitted price

    $3145.66

    Filled price

    $3145.66

    Fee

    $0.00

  8. 2024-06-11T13:30:00.000Z

    Pair

    ETH-USD

    Side

    Buy

    Units

    2.8484134936516874

    Submitted price

    $3536.09

    Filled price

    $3536.09

    Fee

    $70.51

Recorded rows in source order; spacing does not represent elapsed time.

Inspect full UTC times and exact fractional quantities

Scroll sideways to compare all columns. Select a heading to sort.

2024-04-12T20:00:00.000ZETH-USDBuy2.961955932227903$3207.34$3207.34$66.50
2024-04-27T20:00:00.000ZETH-USDSell2.9412222407023076$3240.80$3240.80$66.72
2024-04-28T13:30:00.000ZETH-USDSell0.020733691525595344$3305.35$3305.35$0.48
2024-05-01T13:30:00.000ZETH-USDBuy3.2685513222924385$2896.82$2896.82$66.28
2024-05-04T13:30:00.000ZETH-USDSell3.245671463036391$3133.46$3133.46$71.19
2024-05-04T20:00:00.000ZETH-USDSell0.022719700241254966$3138.92$3138.92$0.50
2024-05-05T13:30:00.000ZETH-USDSell0.00016015901479233055$3145.66$3145.66$0.00
2024-06-11T13:30:00.000ZETH-USDBuy2.8484134936516874$3536.09$3536.09$70.51

Exact drawdown measurement

Read the exact snapshot timestamps and measurement comparison

The largest decline between exported snapshots was 28.28%, from $10704.02 at 2024-06-16T20:00:00.000Z to $7677.45 at 2024-08-05T13:30:00.000Z. The reported maximum drawdown is 28.52%. Explore the trades and holdings around those dates.

Continue exploring

Discussion

Sign in or create a free account to join the discussion.

No comments yet.

Aurora · AI research assistant

Try this in Aurora

Edit the request, then open it in Aurora. You choose when to send it.