Rearview Download

Forex trend, long or flat

Trend following on currency pairs, long or flat: hold a pair while it is above its 100-day average and has risen over the last 50 days, and step aside when it closes below its 50-day average. Each position risks 1% of equity to an ATR stop, counted in units of the pair's base currency. A pair settles in cash at every close, as a future does, and each day it is held it earns or pays carry: its base currency's interest rate less its quote's, from the data's rates.csv. A cash account backs each pair with cash for its full value, so it never borrows.

Exchanges and currencies · world/forex_trend.rvw

language 1
strategy "Forex trend, long or flat" {
  universe   forex
  enter long when close > sma(close, 100) and roc(close, 50) > 0
  rank by    roc(close, 50)
  stop       3 x atr(20)
  size       risk 1% with stop, max 3 positions
  max position 40%
  exit when  close < sma(close, exit_days)
  param      exit_days = 50 in 20..100 step 10
}

Functions it uses

sma, roc, atr

Try it

These need data from more than one exchange or currency: stocks of other exchanges, a forex pair for each currency, and each currency’s interest rates for carry. stocks_and_forex.rvwp holds the market ETF strategy and the forex trend in sleeves of 70% and 30%, rebalanced each month. See Several exchanges’ days and Currencies and forex pairs.

File ▸ New Script from Example adds it to a project. The examples read the sample’s index label, SYN500, and market ETF, SYNSPY; when your data has neither, a sheet asks what to read instead, one of your index labels (or every stock and ETF) and a ticker, so the example runs on your data as it is.

Before you trust what it does on your data, see whether it’s luck: Is this result luck?