Optimization multi symbols on Tick
Optimization multi symbols on Tick
08 Dec 2022, 01:18
Hello everyone, I hope someone can help me.
I'm testing some ideas with multisymbols and I can run the optimization on the bar, but I can't run it on every tick, this is the code:
using System;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TestBot : Robot
{
[Parameter("Stop Loss", Group = "Test", DefaultValue = 80, MinValue = 1, MaxValue = 10000, Step = 1)]
public int Sl { get; set; }
[Parameter("Take Profit", Group = "Test", DefaultValue = 80, MinValue = 1, MaxValue = 10000, Step = 1)]
public int Tp { get; set; }
public Symbol[] MySymbols;
protected override void OnStart()
{
MySymbols = Symbols.GetSymbols("EURUSD", "GBPUSD");
foreach (var symbol in MySymbols)
{
var bars = MarketData.GetBars(TimeFrame, symbol.Name);
bars.BarOpened += Bars_BarOpened;
}
}
private void Bars_BarOpened(BarOpenedEventArgs obj)
{
if (obj.Bars.Last(1).Close > obj.Bars.Last(1).Open)
{
ExecuteMarketOrder(TradeType.Buy, obj.Bars.SymbolName, 1000, "Label", Sl, Tp);
}
else
{
ExecuteMarketOrder(TradeType.Sell, obj.Bars.SymbolName, 1000, "Label", Sl, Tp);
}
}
}
}