Skip to content

ChartRobots

Summary

The interface representing a chart Robot instances collection.Provides properties and events that allow for accessing various information about Robots attached to a chart.

Signature

1
public abstract interface ChartRobots

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
 using cAlgo.API;
 namespace cAlgo.Robots;
 [Robot(AccessRights = AccessRights.None)]
 public class TestExample : Robot
 {
    protected override void OnStart()
    {
        foreach (var chartRobot in ChartRobots)
        {
             Print($"Name: {chartRobot.Name} | InstanceId: {chartRobot.InstanceId} | State: {chartRobot.State} | Type Name: {chartRobot.Type.Name}");
        }
         ChartRobots.RobotAdded += args => Print($"Robot added, {args.Robot.Name}");
         ChartRobots.RobotRemoved += args => Print($"Robot removed, {args.Robot.Name}");
         ChartRobots.RobotModified += args => Print($"Robot modified, {args.Robot.Name}");
         ChartRobots.RobotStarted += args => Print($"Robot started, {args.Robot.Name}");
         ChartRobots.RobotStopped += args => Print($"Robot stopped, {args.Robot.Name}");
        var addedChartRobot = ChartRobots.Add("Sample Break Even");
        addedChartRobot.Start();
    }
 }

Methods

Add (2)

Add (1 of 2)

Summary

Adds a new Robot instance to a chart.

Signature

1
public abstract ChartRobot Add(string name, object[] parameterValues)

Parameters

Name Type Description
name string The name of a Robot.
parameterValues object[] The Robot parameter values or an anonymous object that contains Robot parameter values.

Return Value

ChartRobot

Examples

1
2
3
4
 protected override void Initialize()
 {
     var martingaleBot = ChartRobots.Add("Sample Martingale cBot", 0.01, 10, 10);
 }
1
2
3
4
 protected override void Initialize()
 {
     var martingaleBot = ChartRobots.Add("Sample Martingale cBot", new {InitialQuantity = 0.01, StopLoss = 10, TakeProfit = 10});
 }

Add (2 of 2)

Summary

Adds a new Robot instance to a chart.

Signature

1
public abstract ChartRobot Add(RobotType type, object[] parameterValues)

Parameters

Name Type Description
type RobotType The type of Robot, you can get RobotType from AlgoRegistry.
parameterValues object[] The Robot parameter values or an anonymous object that contains Robot parameter values.

Return Value

ChartRobot

Examples

1
2
3
4
5
 protected override void Initialize()
 {
     var martingaleBotType = AlgoRegistry.Get("Sample Martingale cBot", AlgoKind.Robot) as RobotType;
     var martingaleBot = ChartRobots.Add(martingaleBotType, 0.01, 10, 10);
 }
1
2
3
4
5
 protected override void Initialize()
 {
     var martingaleBotType = AlgoRegistry.Get("Sample Martingale cBot", AlgoKind.Robot) as RobotType;
     var martingaleBot = ChartRobots.Add(martingaleBotType, new {InitialQuantity = 0.01, StopLoss = 10, TakeProfit = 10});
 }

See Also

Remove

Summary

Removes a Robot instance from a chart.

Signature

1
public abstract bool Remove(ChartRobot robot)

Parameters

Name Type Description
robot ChartRobot The ChartRobot to be removed from a chart.

Return Value

bool

Properties

Item

Signature

1
public abstract ChartRobot Item {get;}

Return Value

ChartRobot

Count

Summary

Gets the number of all Robots attached to a chart.

Signature

1
public abstract int Count {get;}

Return Value

int

Events

RobotAdded

Summary

Occurs when a Robot is added to a chart.

Signature

1
public abstract event Action<ChartRobotAddedEventArgs> RobotAdded;

RobotRemoved

Summary

Occurs when a Robot is removed from a chart.

Signature

1
public abstract event Action<ChartRobotRemovedEventArgs> RobotRemoved;

RobotModified

Summary

Occurs when a chart Robot instance is modified.

Signature

1
public abstract event Action<ChartRobotModifiedEventArgs> RobotModified;

RobotStarted

Summary

Occurs when a chart Robot instance is started.

Signature

1
public abstract event Action<ChartRobotStartedEventArgs> RobotStarted;

RobotStopped

Summary

Occurs when a chart Robot instance is stopped.

Signature

1
public abstract event Action<ChartRobotStoppedEventArgs> RobotStopped;