In Multi Markets Strategy, Markets is a property of type Market[] containing all the selected markets. You can access a concrete market with array index operator - Markets[0] for first selected market, Markets[1] for second etc. as you can see in the editor's sidebar.
// Write current price of the first market in the list of selected markets to the logs
Log("Current price of " + Markets[0].Asset + " on " + Markets[0].Exchange + ": " + Markets[0].CurrentPrice);
// Write current price of the second market in the list of selected markets to the logs
Log("Current price of " + Markets[1].Asset + " on " + Markets[1].Exchange + ": " + Markets[1].CurrentPrice);
using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.SMA;
public class MyStrategy : MultiMarketsStrategy
{
private Bars hourlyBarsFirstAsset;
private Bars hourlyBarsSecondAsset;
private Market firstMarket;
private Market secondMarket;
public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
{
firstMarket = Markets[0];
secondMarket = Markets[1];
hourlyBarsFirstAsset = data.Bars(BarPeriodType.Hour, 1).OnMarket(firstMarket).WithOffset(25);
hourlyBarsSecondAsset = data.Bars(BarPeriodType.Hour, 1).OnMarket(secondMarket).WithOffset(25);
}
public override void RegisterActions()
{
OnUpdateOf(hourlyBarsFirstAsset).Do(() =>
{
Log("Current price of " + firstMarket.Asset + " on " + firstMarket.Exchange + ": " + firstMarket.CurrentPrice);
});
OnUpdateOf(hourlyBarsSecondAsset).Do(() =>
{
Log("Current price of " + secondMarket.Asset + " on " + secondMarket.Exchange + ": " + secondMarket.CurrentPrice);
});
}
}