Skip to content

ChartDraggables

Summary

Represents collection of a chart area draggables.

Signature

1
public abstract interface ChartDraggables

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 [Robot(AccessRights = AccessRights.None)]
 public class TestExample : Robot
 {
    private const string Label = "Draggable";
    protected override void OnStart()
    {
        var openPositionButton = new Button {Text = "Open Position"};
        openPositionButton.Click += _ => ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, Label);
        var closePositionsButton = new Button {Text = "Close Position"};
        closePositionsButton.Click += _ => Positions.Find(Label)?.Close();
        var panel = new StackPanel {Orientation = Orientation.Vertical, BackgroundColor = Color.Red};
        panel.AddChild(openPositionButton);
        panel.AddChild(closePositionsButton);
        var draggable = Chart.Draggables.Add();
        draggable.ShowGrip = true;
        draggable.Child = panel;
        draggable.LocationChanged += args => Print($"Draggable Location Changed: {args.Draggable.X}, {args.Draggable.Y}");
    }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 import clr
 clr.AddReference("cAlgo.API")
 # Import cAlgo API types
 from cAlgo.API import *
 # Import trading wrapper functions
 from robot_wrapper import *
 class Test():
     Label = "Test"
     def on_start(self):
         openPositionButton = Button()
         openPositionButton.Text = "Open Position"
         openPositionButton.Click += lambda _ : api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, api.Symbol.VolumeInUnitsMin, self.Label)
         closePositionsButton = Button()
         closePositionsButton.Text = "Close Position"
         closePositionsButton.Click += lambda _ : api.Positions.Find(self.Label).Close()
         panel = StackPanel()
         panel.Orientation = Orientation.Vertical
         panel.BackgroundColor = Color.Red
         panel.AddChild(openPositionButton)
         panel.AddChild(closePositionsButton)
         draggable = api.Chart.Draggables.Add()
         draggable.ShowGrip = True
         draggable.Child = panel
         draggable.LocationChanged += lambda args : print(f"Draggable Location Changed: {args.Draggable.X}, {args.Draggable.Y}")

Methods

Add

Summary

Adds a draggable to chart area.

Signature

1
public abstract ChartDraggable Add()

Return Value

ChartDraggable

Remove

Summary

Removes a draggable from chart area.

Signature

1
public abstract void Remove(ChartDraggable draggable)

Parameters

Name Type Description
draggable ChartDraggable Draggable

Return Value

void

Properties

Count

Summary

Gets count of draggables.

Signature

1
public abstract int Count {get;}

Return Value

int