Referencing a Robot

Created at 28 Nov 2012, 20:57
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Uche's avatar

Uche

Joined 25.10.2012

Referencing a Robot
28 Nov 2012, 20:57


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


Thanks


@Uche
Replies

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

 



 


@admin

Uche
29 Nov 2012, 22:43

Thanks

Okey-dokey lets code.


@Uche

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.

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

PanagiotisCharalampous
17 Feb 2020, 09:41

Hi Vipin,

This example is not supported anymore. Read more here.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous