Multi-Instrument Optimizations
Created at 08 Jul 2020, 03:25
Multi-Instrument Optimizations
08 Jul 2020, 03:25
Hi,
I'm successfully backtesting my cBots with multiple instruments. For some reason when I try to run an optimization though this morning I don't get any results / shows the different run combinations but nothing runs.
If I restrict my code to only one instrument in my list (ie: one name in PairsToTrade variable below) I get typical optimization results for each pass.
Does cAlgo allow calls to multiple instruments in optimisztions? IT allows multiple timeframes, and in backtesting, so I can't work out why this isn't working.
code overview below:
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class myRobot: Robot
{
const int num_instruments = 6;
public enum PairsToTrade
{
EURUSD,
GBPUSD,
AUDUSD,
XTIUSD,
XAUUSD,
AUS200
}
private AS_1_1_HighLow[] AS_HL_trigger = new AS_1_1_HighLow[num_instruments];
private Bars[] AS_RSI_Div_S_bars = new Bars[num_instruments];
private AverageTrueRange[] trailTickATR = new AverageTrueRange[num_instruments];
private Bars[] mainBars = new Bars[num_instruments];
protected override void OnStart()
{
// Subscribe to the positions opened event.
Positions.Opened += PositionsOnOpened;
// Subscribe to the positions closed event.
Positions.Closed += PositionsOnClosed;
int i = 0;
foreach (string myPair in Enum.GetNames(typeof(PairsToTrade)))
{
AS_RSI_Div_S_bars[i] = MarketData.GetBars(TimeFrame, myPair);
// pass correct instrument and TF to our custom indicator
AS_RSI_Div_S[i] = Indicators.GetIndicator<AS_RSI_Divergence_Short>(AS_RSI_Div_S_bars[i], RSIPeriod, ...other vars);
// ATR for our trail exit
mainBars[i] = MarketData.GetBars(TimeFrame, myPair);
trailTickATR[i] = Indicators.AverageTrueRange(mainBars[i], tickExit_trail_ATR_period, MovingAverageType.Simple);
i++;
}
}
///
protected override void OnBar()
{
foreach (string myPair in Enum.GetNames(typeof(PairsToTrade)))
{
int SymIndex = mySymIndex(myPair); // returns correct index to reference each series
////
// do something
// eg:
DataSeries H = MarketData.GetBars(TimeFrame, myPair).HighPrices;
DataSeries L = MarketData.GetBars(TimeFrame, myPair).LowPrices;
DataSeries C = MarketData.GetBars(TimeFrame, myPair).ClosePrices;
// example reference ATR timeseries:
double testOut = trailTickATR[SymIndex].Result.LastValue;
////////
}
}
PanagiotisCharalampous
08 Jul 2020, 08:33
Hi n2535904,
Optimization for mutlisymbol strategies is not supported at the moment.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous