TradeType
enum cAlgo.API
DesktopCLICloud
The direction of a trade order.
Definition
public enum TradeType
Namespace: cAlgo.API · Group: Trading
Remarks
Indicates the trade direction, whether it is a Buy or a Sell trade.
Examples
Example 1
var tradeType = Bars.ClosePrices.Last(1) > Bars.OpenPrices.Last(1) ? TradeType.Buy : TradeType.Sell;
var result = ExecuteMarketOrder(tradeType, SymbolName, 10000, "myLabel", 20, 40);
Print("{0} order executed: {1}", tradeType, result.IsSuccessful);
tradeType = TradeType.Buy if api.Bars.ClosePrices.Last(1) > api.Bars.OpenPrices.Last(1) else TradeType.Sell
result = api.ExecuteMarketOrder(tradeType, api.SymbolName, 10000, "myLabel", 20, 40)
api.Print(f"{tradeType} order executed: {result.IsSuccessful}")
Example 2
var position = Positions.Find("myLabel", "EURUSD", TradeType.Sell);
if (position == null)
PlaceLimitOrder(TradeType.Sell, "EURUSD", 10000, Symbols.GetSymbol("EURUSD").Ask + 0.0020, "myLabel");
position = api.Positions.Find("myLabel", "EURUSD", TradeType.Sell)
if position is None:
api.PlaceLimitOrder(TradeType.Sell, "EURUSD", 10000, api.Symbols.GetSymbol("EURUSD").Ask + 0.0020, "myLabel")
Values
| Name | Value | Description |
|---|---|---|
Buy | 0 | Represents a Buy order. |
Sell | 1 | Represents a Sell order. |