- Home
- Forum
- cTrader News & Announcements
- Multi-symbol robots and indicators
Multi-symbol robots and indicators
Multi-symbol robots and indicators
Hi gunning.ernie,
The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { var EURUSD = MarketData.GetSymbol("EURUSD"); var GBPUSD = MarketData.GetSymbol("GBPUSD"); var EURJPY = MarketData.GetSymbol("EURJPY"); var USDJPY = MarketData.GetSymbol("USDJPY"); } protected override void OnTick() { Print("tick"); } protected override void OnStop() { // Put your deinitialization logic here } } }
In this case, OnTick() will be invoked for all four symbols.
Let me know if this helps you.
Best Regards,
Panagiotis
RE:
Panagiotis Charalampous said:
Hi gunning.ernie,
The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { var EURUSD = MarketData.GetSymbol("EURUSD"); var GBPUSD = MarketData.GetSymbol("GBPUSD"); var EURJPY = MarketData.GetSymbol("EURJPY"); var USDJPY = MarketData.GetSymbol("USDJPY"); } protected override void OnTick() { Print("tick"); } protected override void OnStop() { // Put your deinitialization logic here } } }In this case, OnTick() will be invoked for all four symbols.
Let me know if this helps you.
Best Regards,
Panagiotis
Thanks Panagiotis, This helps allot. This is my first stab at cALGO and i have noted on other post the same...they are old. You think certain functionality is not there then it is...
Thanks again for the effort.
Ernie
Backtesting of Multiple Symbols in on bot still not supported?
Multi-symbol robots and indicators - Which Symbol Invoked OnTick?????
Hi Panagiotis or anyone else who knows
on testing this code above the cAlgo Symbol Interface only returns symbol data for the symbol that is selected with calgo to run the robot with but will invoke on ticks from the four symbols entered in the OnStart method.
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { var EURUSD = MarketData.GetSymbol("EURUSD"); var GBPUSD = MarketData.GetSymbol("GBPUSD"); var EURJPY = MarketData.GetSymbol("EURJPY"); var USDJPY = MarketData.GetSymbol("USDJPY"); } protected override void OnTick() { Print("Symbol -" + Symbol.Code + " | Bid = " + Symbol.Bid ); } protected override void OnStop() { // Put your deinitialization logic here } } }
How do i tell OnTick Method or Symbol Interface which Symbol Invoked it?
Hi GammaQuant,
Unfortunately you cannot tell for which Symbol was the OnTick() called.
Best Regards,
Panagiotis
RE:
Panagiotis Charalampous said:
Hi GammaQuant,
Unfortunately you cannot tell for which Symbol was the OnTick() called.
Best Regards,
Panagiotis
Hi Panagiotis
thank you for the last reply
Ok so i was trying to make some kind of work around property that invoke my own tick method on change but cAlgo wont build and gives me an error:
Unable to load assembly: "EurUsd" parameter must be an auto-property
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class MultiSymbolTest : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } public SymbolEvent EurUsd { get { return EurUsd; } set { var eurUsd = MarketData.GetSymbol("EURUSD"); EurUsd = new SymbolEvent { Bid = eurUsd.Bid, Ask = eurUsd.Ask }; MyOnTick(eurUsd); } } protected override void OnStart() { // Put your initialization logic here var EURUSD = MarketData.GetSymbol("EURUSD"); //var GBPUSD = MarketData.GetSymbol("GBPUSD"); //var EURJPY = MarketData.GetSymbol("EURJPY"); //var USDJPY = MarketData.GetSymbol("USDJPY"); } /*protected override void OnTick() { // Put your core logic here Print("Symbol -" + Symbol.Code + " | Bid = " + Symbol.Bid); }*/ private void MyOnTick(Symbol symbol) { Print("Symbol -" + Symbol.Code + " | Bid = " + Symbol.Bid); } protected override void OnStop() { // Put your deinitialization logic here } } public struct SymbolEvent { public double Ask; public double Bid; } }
Wht is the situation with preset properties and calgo?
RE:
Panagiotis Charalampous said:
Hi gunning.ernie,
The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { var EURUSD = MarketData.GetSymbol("EURUSD"); var GBPUSD = MarketData.GetSymbol("GBPUSD"); var EURJPY = MarketData.GetSymbol("EURJPY"); var USDJPY = MarketData.GetSymbol("USDJPY"); } protected override void OnTick() { Print("tick"); } protected override void OnStop() { // Put your deinitialization logic here } } }In this case, OnTick() will be invoked for all four symbols.
Let me know if this helps you.
Best Regards,
Panagiotis
Hi!
Nice Trading Software! I came to the point, that I need to "subscribe" to multiple Symbols in one of my strategies. Now I just found your comment on this behaviour. Sadly there is nothing about this subject in the reference documentation (the documentation is really very minimalistic!). Would be nice to have more information about the exact behaviour of GetSymbol()! Clearly it would be nice to referece the Symbol which is updated in the OnTick() Callback Attributes. But I have one more request. Is it possible to Unsubscribe from a specific Symbol while the Bot / Indicator is running.
Best regards
RE:
Panagiotis Charalampous said:
Hi gunning.ernie,
The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { var EURUSD = MarketData.GetSymbol("EURUSD"); var GBPUSD = MarketData.GetSymbol("GBPUSD"); var EURJPY = MarketData.GetSymbol("EURJPY"); var USDJPY = MarketData.GetSymbol("USDJPY"); } protected override void OnTick() { Print("tick"); } protected override void OnStop() { // Put your deinitialization logic here } } }In this case, OnTick() will be invoked for all four symbols.
Let me know if this helps you.
Best Regards,
Panagiotis
Hi!
Nice Trading Software! I came to the point, that I need to "subscribe" to multiple Symbols in one of my strategies. Now I just found your comment on this behaviour. Sadly there is nothing about this subject in the reference documentation (the documentation is really very minimalistic!). Would be nice to have more information about the exact behaviour of GetSymbol()! Clearly it would be nice to referece the Symbol which is updated in the OnTick() callback attributes. But I have one more request. Is it possible to Unsubscribe from a specific Symbol while the Bot / Indicator is running.
Best regards
RE:
Panagiotis Charalampous said:
Hi GammaQuant,
Unfortunately you cannot tell for which Symbol was the OnTick() called.
Best Regards,
Panagiotis
Disappointing to see there is no multi-instrument support for back tests. Can you advise whether this functionality is likely to be available in future?
Thanks,
Finn