Referencing a Robot
Referencing a Robot
28 Nov 2012, 20:57
How do I reference a Robot from another, including input parameters like Volume.
Thanks
Replies
buccinator
04 Sep 2019, 11:56
RE:
admin said:
You may extend the class name of the robot you are trying to reference.
//#reference: ..\Robots\test_Referenced.algo // ------------------------------------------------------------------------------- // // This is a Template used as a guideline to build your own Robot. // Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API. // // ------------------------------------------------------------------------------- using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot] public class test_ReferenceRobot : test_Referenced { protected override void OnStart() { base.Volume = 100; base.OnStart(); } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
// ------------------------------------------------------------------------------- // // This is a Template used as a guideline to build your own Robot. // Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API. // // ------------------------------------------------------------------------------- using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot] public class test_Referenced : Robot { [Parameter(DefaultValue = 10000, MinValue = 0)] public int Volume { get; set; } protected override void OnStart() { Print("test_Referenced Volume {0}", Volume); } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
for anyone interested it doing this it seems you have to remove the [Robot] line from the base class.
https://ctrader.com/forum/calgo-support/3827?page=1
@buccinator
driftingprogrammer
16 Feb 2020, 14:29
Visual Studio Editor Warnings and errors
buccinator said:
admin said:
You may extend the class name of the robot you are trying to reference.
//#reference: ..\Robots\test_Referenced.algo // ------------------------------------------------------------------------------- // // This is a Template used as a guideline to build your own Robot. // Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API. // // ------------------------------------------------------------------------------- using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot] public class test_ReferenceRobot : test_Referenced { protected override void OnStart() { base.Volume = 100; base.OnStart(); } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
// ------------------------------------------------------------------------------- // // This is a Template used as a guideline to build your own Robot. // Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API. // // ------------------------------------------------------------------------------- using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot] public class test_Referenced : Robot { [Parameter(DefaultValue = 10000, MinValue = 0)] public int Volume { get; set; } protected override void OnStart() { Print("test_Referenced Volume {0}", Volume); } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
for anyone interested it doing this it seems you have to remove the [Robot] line from the base class.
Following the steps mentioned here Visual Studio Code Editor continues to show compilation errors (although the build does not throw any errors and is successful) which makes writing code extremely annoying in Visual Studio.
Is there i recommended way to get rid of these compilation warnings inside Visual Studio 2017.
Thanks in advance,
Cheers,
Vipin.
@driftingprogrammer
PanagiotisCharalampous
17 Feb 2020, 09:41
Hi Vipin,
This example is not supported anymore. Read more here.
Best Regards,
Panagiotis
@PanagiotisCharalampous
admin
29 Nov 2012, 16:38
You may extend the class name of the robot you are trying to reference.
@admin