Examples

Title: Simple Moving Average Strategy for Bar Analysis

Strategy description:

I am interested in testing a simple moving average strategy using bar analysis. The strategy involves using moving average, to identify buy and sell signals.

Here are the specifics of the strategy:

  • The moving average will be calculated over a period of 10 bars.
  • If the bar fully closed upper moving average, a buy signal will be generated on the next day. Conversely, if bar fully closed lower moving average, a sell signal will be generated on the next day.
  • The strategy will be tested on daily bars of the all NYSE market over a period of 1 year, from January 1, 2022, to December 31, 2022.
  • Trading will be executed at the close of the bar on which the signal is generated.
  • The position size will be fixed at 1% of the portfolio value.
  • Stop-loss orders will be placed at 2% below the entry price for long positions and 2% above the entry price for short positions.
  • Take profit is and of the next day. (open_price – close_price)

Report:

I would like you to develop a back testing tool that can simulate trading based on this strategy and provide me with the following metrics:

Title: Back test Report – Simple Moving Average Strategy

  • Total net profit
  • Profit factor
  • Total numbers of trades
  • Percent profitable
  • Winning trades
  • Losing trades
  • Avg. Trade net profit
  • Max. winning trade
  • Max. losing trade
  • Max. Consecutiv winning trades
  • Max. Consecutiv losing trades
  • Max. drawdown
  • Value
  • Net Profit as % drowdawn

Test Parameters:

  • Security: NYSE market
  • Test Period: January 1, 2022, to December 31, 2022
  • Bar Interval: Daily bars
  • Position Size: 1% of portfolio value
  • Stop-loss Orders: Placed at 2% below the entry price for long positions and 2% above the entry price for short positions
  • Take profit is and of the next day. (open_price – close_price)

Trade Log:

  • Table listing all trades executed during the test period, including entry date, exit date, position type, entry price, exit price, profit/loss, and holding period