Skip to content

ModifyPositionAsync Method (4)

ModifyPositionAsync (1 of 4)

Summary

Modify Position in asynchronous execution mode

Signature

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

Parameters

Name Type Description
position Position Position to modify
volume double New volume
callback Action Method that is called when position is modified

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

ModifyPositionAsync (2 of 4)

Summary

Modify Position in asynchronous execution mode

Signature

1
public TradeOperation ModifyPositionAsync(Position position, double? stopLoss, double? takeProfit, Action<TradeResult> callback)

Parameters

Name Type Description
position Position Position to modify
stopLoss double? New stop loss price
takeProfit double? New take profit price
callback Action Method that is called when position is modified

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

ModifyPositionAsync (3 of 4)

Summary

Modify Position in asynchronous execution mode

Signature

1
public TradeOperation ModifyPositionAsync(Position position, double? stopLoss, double? takeProfit, bool hasTrailingStop, Action<TradeResult> callback)

Parameters

Name Type Description
position Position Position to modify
stopLoss double? New stop loss price
takeProfit double? New take profit price
hasTrailingStop bool Enable/disable TrailingStop for position
callback Action Method that is called when position is modified

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

ModifyPositionAsync (4 of 4)

Summary

Modify Position in asynchronous execution mode

Signature

1
public TradeOperation ModifyPositionAsync(Position position, double? stopLoss, double? takeProfit, bool hasTrailingStop, StopTriggerMethod? stopLossTriggerMethod, Action<TradeResult> callback)

Parameters

Name Type Description
position Position Position to modify
stopLoss double? New stop loss price
takeProfit double? New take profit price
hasTrailingStop bool Enable/disable TrailingStop for position
stopLossTriggerMethod StopTriggerMethod? Trigger method for position's StopLoss
callback Action Method that is called when position is modified

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: July 1, 2022

Comments