We've included this script as an example to get you started.

Golden Cross strategies work on the principle that a short moving average indicator crossing above a longer moving average indicates a market has turned bullish, and vice versa.

This strategy is profitable in markets that have enough volatility for the price to continue moving in the direction indicated by the cross. It will make a loss in flat markets.

This script registers 2 external variables, 'shortSMA' and 'longSMA'. These are the number of periods the SMA (Simple Moving Average) indicator averages the close prices over. Typical values range from 2 to 10 for shortSMA and 10 to 50 for longSMA. These values are entered when starting a backtest or live trading session. The 'Optimize' tab can be used for repeatedly backtesting every permutation over a range of these to determine the best values for the market conditions of the given instrument and time period.

You may wish to create externals for the stop loss and take profit margins, which are currently baked into the code below.

This strategy only allows one position to be open at any one time to better manage exposure to risk for each individual trade..