I am creating and testing strategies in R code and using systemic investor toolbox(SIT) package as the backtesting tool. I copied a SIT backtesting code from a website and made small changes to make below code and its working fine.
#backtesing long Apple
#long when fast MA is greater than slow MA and rsi less than 50 else exit
library(quantmod)
library(SIT)
data <- new.env()
# Load historical data and adjusts for splits and dividends
tickers = spl('AAPL')
getSymbols(tickers, src = 'yahoo', from = '2000-01-01', env = data, auto.assign = T)
for(i in ls(data)) data[[i]] = adjustOHLC(data[[i]], use.Adjusted=T)
#Calculate the moving averages and lag them one day to prevent lookback bias
close<-Cl(data[['AAPL']])
MAF <- lag(SMA(close,50))
MAC <- lag(SMA(close,100))
rsi<- RSI(close,25)
#Sets backtesting environment
bt.prep(data, align='remove.na')
prices = data$prices
#Create a empty list for attaching the models to at a later stage
models = list()
#Specify the weights to be used in the backtest
data$weight[] = NA #Zero out any weights from previous
data$weight[] = ifelse(MAF>MAC&rsi<50,1,0) #If price of SPY is above the SMA then buy
#Call the function to run the backtest given the data, which contains the prices and weights.
models$technical_model = bt.run.share(data, trade.summary=T)
#Plot equity curve and export the trades list to csv
plot(models$technical_model$equity, main="Equity Curve")
Currently to check the quality of my strategy; I backtest using above code against 10 randomly handpicked stocks and indexs in my portfolio (AAPL,GOOG, GE,GS,PFE,AA,SPY,^GSPC,XOM,C) and then manually take averages of the results(eg drawdown, sharpe, profit factor etc) to check the strategy viability. But doing this takes lots of my time and energy . How can I backtest my strategy against my whole protofolio instead of one by one in SIT to get a best estimate of my strategy. What kind of modifications should I do to the above code?