Skip to content

ClosePositionAsync Method (3)

ClosePositionAsync (1 of 3)

Summary

Close a position in asynchronous execution mode

Signature

1
public TradeOperation ClosePositionAsync(Position position, Action<TradeResult> callback)

Parameters

Name Type Description
position Position The position to close
callback Action The action when the position closes

Return Value

TradeOperation

Declaring Type

cAlgo.API.Robot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 namespace cAlgo.Robots
 {
 [Robot]
 public class myCBot : Robot
 {
     protected override void OnStart()
     {
         //This method is called when the cBot is being started, once.
     }
     protected override void OnBar()
     {
         // Called on each incoming Bar.
     }
     protected override void OnTick()
     {
         // Called on each incoming tick.
     }
     protected override void OnError(Error error)
     {
         Print("There has been an Error");
     }
     protected override void OnStop()
     {
         //This method is called when the cBot is being stoped.
     }
}

ClosePositionAsync (2 of 3)

Summary

Close a position in asynchronous execution mode

Signature

1
public TradeOperation ClosePositionAsync(Position position, long volume, Action<TradeResult> callback)

Parameters

Name Type Description
position Position The position to close
volume long The volume to close
callback Action The action when the position closes

Return Value

TradeOperation

Declaring Type

cAlgo.API.Robot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 namespace cAlgo.Robots
 {
 [Robot]
 public class myCBot : Robot
 {
     protected override void OnStart()
     {
         //This method is called when the cBot is being started, once.
     }
     protected override void OnBar()
     {
         // Called on each incoming Bar.
     }
     protected override void OnTick()
     {
         // Called on each incoming tick.
     }
     protected override void OnError(Error error)
     {
         Print("There has been an Error");
     }
     protected override void OnStop()
     {
         //This method is called when the cBot is being stoped.
     }
}

ClosePositionAsync (3 of 3)

Summary

Close a position in asynchronous execution mode

Signature

1
public TradeOperation ClosePositionAsync(Position position, double volume, Action<TradeResult> callback)

Parameters

Name Type Description
position Position The position to close
volume double The volume to close
callback Action The action when the position closes

Return Value

TradeOperation

Declaring Type

cAlgo.API.Robot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 namespace cAlgo.Robots
 {
 [Robot]
 public class myCBot : Robot
 {
     protected override void OnStart()
     {
         //This method is called when the cBot is being started, once.
     }
     protected override void OnBar()
     {
         // Called on each incoming Bar.
     }
     protected override void OnTick()
     {
         // Called on each incoming tick.
     }
     protected override void OnError(Error error)
     {
         Print("There has been an Error");
     }
     protected override void OnStop()
     {
         //This method is called when the cBot is being stoped.
     }
}

Last update: March 23, 2023