|
Kiran
2016-04-23 14:30:02
|
|
I have a simple system (below) for 48 futures symbols and followed the instructions from the Blog - http://www.quantshare.com/sa-502-how-to-backtest-each-stock-or-asset-individually&kbaseid=blog-502-7381-3402
- I added the per-symbol Buy code to the script below and also the Money Mgmt script to report the symbol in the Optimization report described below ..
I get all results as 0 when i Optimize. When i backtest 1 symbol at a time, the script works fine.
Note - since i'm trading futures, i've also added another MM script to trade only 1 contract at a time - Buy/Short a Fixed # of Shares, Shares=1. Hope that's not interfering
//System ..
// Buy rules
Optimize("buyPer", 3, 7, 2);
buyRule = ema(close,buyPer)>ref(ema(close,buyPer),1) && close>open;
lt=-0.1; //Optimize("lt",-0.1,0.2,0.1);
SetSimTiming(_Buy,_Limit,0);
BuyPrice(close-lt*atr(10),1);
buy = buyRule;
//Backtest 1 symbol at a time
Optimize("sindex", 0, SymbolIndex(name(), -1), 1);
buy = buy and SymbolIndex(name(), sindex);
//Sell rule
sell = ema(close,buyPer)<ref(ema(close,buyPer),1);
//MM script
//On Start Simulation
Functions.AddReportMetric("Symbol", "");
//OnEndSimulation
MMPosition[] pos = Portfolio.GetAllPositions();
if(pos.Length > 0)
{
Variables.SetVariable("Symbol", pos[0].Symbol);
}
|
|