Skip to content

TradeType

Summary

The direction of a trade order.

Remarks

Indicates the trade direction, whether it is a Buy or a Sell trade.

Signature

1
public enum TradeType

Namespace

cAlgo.API

Examples

1
 ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 20000);
1
 Position position =  Positions.Find("myLabel", Symbol, TradeType.Sell);
1
 PlaceLimitOrder(TradeType.Buy, Symbol.Name, 10000, Symbol.Bid);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 using cAlgo.API;
 namespace cAlgo.Robots
 {
     // This sample cBot shows how to use the TradeType
     // TradeType is used to set an order trade side or direction
     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class TradeTypeSample : Robot
     {
         [Parameter("Trade Type", DefaultValue = TradeType.Buy)]
         public TradeType TradeType { get; set; }
         protected override void OnStart()
         {
             ExecuteMarketOrder(TradeType, SymbolName, Symbol.VolumeInUnitsMin);
         }
     }
 }
1
 api.ExecuteMarketOrder(TradeType.Buy, api.Symbol.Name, 20000)
1
 position = api.Positions.Find("myLabel", api.Symbol, TradeType.Sell)
1
 api.PlaceLimitOrder(TradeType.Buy, api.Symbol.Name, 10000, api.Symbol.Bid)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 import clr
 clr.AddReference("cAlgo.API")
 # Import cAlgo API types
 from cAlgo.API import *
 # Import trading wrapper functions
 from robot_wrapper import *
 class Test():
     def on_start(self):
         # TradeType is a parameter of type TradeType Enum defined in cBot C# file
         api.ExecuteMarketOrder(api.TradeType, api.SymbolName, api.Symbol.VolumeInUnitsMin)

Fields

Buy

Summary

Represents a Buy order.

Signature

1
TradeType.Buy;

Return Value

TradeType

Examples

1
 ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 10000);
1
 var result = PlaceLimitOrder(TradeType.Buy, Symbol.Name, 10000, Symbol.Bid);
1
 api.ExecuteMarketOrder(TradeType.Buy, api.Symbol.Name, 10000);
1
 result = api.PlaceLimitOrder(TradeType.Buy, api.Symbol.Name, 10000, api.Symbol.Bid);

Sell

Summary

Represents a Sell order.

Signature

1
TradeType.Sell;

Return Value

TradeType

Examples

1
 ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 10000);
1
 var result = PlaceLimitOrder(TradeType.Sell, Symbol.Name, 10000, Symbol.Ask);
1
 api.ExecuteMarketOrder(TradeType.Sell, api.Symbol.Name, 10000)
1
 result = api.PlaceLimitOrder(TradeType.Sell, api.Symbol.Name, 10000, api.Symbol.Ask)