Backtesting Example

The following code demonstrates how to launch a backtester job from the custom exploration code. See Working with Explorations chapter for more information about exploration features included in Chartsy|One.

The following example backtests a simple trading strategy based on a Shark32 candlestick patterns. The strategy is long only and opens a long position immediately when the price breaks above the highest high bar in the formation. The stop loss is placed one tick below the low of the candlestick formation. The opened position is closed when 12% take profit is reached or stop loss is reached or after spending 7 days on a position, whichever occurs first.

The script launches a series of 100 backtests each performed against k-highest-volume stocks.

When an exploration with the given code is launched the backtest result table is displayed, similar to the one shown below.