Best way of getting MultiSymbol TickData
Created at 15 Feb 2020, 16:09
SH
Best way of getting MultiSymbol TickData
15 Feb 2020, 16:09
Hi Community,
Is there a better way to get multisymbol tick data(ask/bid/name/time) than the way i'm doing it now (see program below)?
and @CTDN Why isn't time in the tick info?
using System;
using System.Linq;
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 TickEventCheck : Robot
{
Symbol NOKJPY, AUDCAD;
Ticks tNOKJPY, tAUDCAD;
protected override void OnStart()
{
NOKJPY = Symbols.GetSymbol("NOKJPY");
NOKJPY.Tick += SymbolTick;
tNOKJPY = MarketData.GetTicks("NOKJPY");
AUDCAD = Symbols.GetSymbol("AUDCAD");
AUDCAD.Tick += SymbolTick;
tAUDCAD = MarketData.GetTicks("AUDCAD");
}
protected override void OnTick()
{
Print("OT:" + Symbol.Name, " ", Symbol.Ask, " ", Symbol.Bid);
}
private void SymbolTick(SymbolTickEventArgs symbolTick)
{
DateTime TickTime = (symbolTick.SymbolName == "AUDCAD" ? tAUDCAD : tNOKJPY).LastTick.Time;
Print("ST:" + symbolTick.SymbolName, " ", symbolTick.Ask, " ", symbolTick.Bid, " ", TickTime);
}
}
}
Best rgds,
Replies
Shares4UsDevelopment
17 Feb 2020, 13:52
RE: RE:
Thanks for thinking with me, but I should elaborate a little more on the problem I guess,
The problem is obtaining the tick time which is not a property of SymbolTickEventArgs.
@Shares4UsDevelopment
firemyst
17 Feb 2020, 08:40
RE:
Shares4UsDevelopment said:
Yes, there's a much better, and cleaner way. Create a Dictionary object with your symbols as the key and the function as the value.
Something like (this code isn't exact as I'm doing this off the cuff) :
And then your SymbolTick function turns into something like:
@firemyst