Referencing a Robot

Uche's avatar

Uche since: 25 Oct 2012;

  28 Nov 2012, 20:57
Referencing a Robot

How do I reference a Robot from another, including input parameters like Volume.


Thanks

{profit=true;}
admin's avatar

admin since: 30 Nov -0001;

  29 Nov 2012, 16:38

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
        }
    }
}

 



TRADERS FIRSTâ„¢
Uche's avatar

Uche since: 25 Oct 2012;

  29 Nov 2012, 22:43

Thanks

Okey-dokey lets code.

{profit=true;}

buccinator since: 04 Aug 2019;

  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

driftingprogrammer's avatar

driftingprogrammer since: 08 Dec 2019;

  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.

https://ctrader.com/forum/calgo-support/3827?page=1

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@gmail.com
PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  17 Feb 2020, 09:41

Hi Vipin,

This example is not supported anymore. Read more here.

Best Regards,

Panagiotis 

Join us on Telegram

Head of Community Management at cTrader