Skip to content

StopTriggerMethod

enum cAlgo.API

DesktopCLICloud

The trigger side for the Stop Orders.

Definition

public enum StopTriggerMethod

Namespace: cAlgo.API · Group: Trading

Examples

using cAlgo.API;

namespace cAlgo.Robots
{
    // This sample shows how to use StopTriggerMethod of orders to control their execution price
    public partial class StopTriggerMethodSample : Robot
    {
        protected override void OnStart()
        {
            // Market order whose stop loss uses the selected trigger method
            ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, "StopTriggerMethod Test", 10, 10, string.Empty, false, StopTriggerMethod);

            // Stop order whose entry and stop loss both use the selected trigger method
            var target = Symbol.Bid + 100 * Symbol.PipSize;
            PlaceStopOrder(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin, target, "StopTriggerMethod Test", 10, 10, ProtectionType.Relative, null, string.Empty, false, StopTriggerMethod, StopTriggerMethod);

            foreach (var position in Positions)
                Print("Position {0} stop loss trigger method: {1}", position.Id, position.StopLossTriggerMethod);
        }
    }
}
def on_start(self):
    api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, api.Symbol.VolumeInUnitsMin, "StopTriggerMethod Test", 10, 10, "", False, api.StopTriggerMethod)

    target = api.Symbol.Bid + 100 * api.Symbol.PipSize
    api.PlaceStopOrder(TradeType.Buy, api.SymbolName, api.Symbol.VolumeInUnitsMin, target, "StopTriggerMethod Test", 10, 10, ProtectionType.Relative, None, "", False, api.StopTriggerMethod, api.StopTriggerMethod)

    for position in api.Positions:
        api.Print(f"Position {position.Id} stop loss trigger method: {position.StopLossTriggerMethod}")
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "Parameters": [
    {
      "Name": "StopTriggerMethod",
      "DisplayName": "Stop Trigger Method",
      "Type": "Enum",
      "EnumTypeFullName": "cAlgo.API.StopTriggerMethod",
      "DefaultValue": "Trade"
    }
  ]
}

Values

Name Value Description
Trade 0 Trade method uses default trigger behavior for Stop orders. Buy order and Stop Loss for Sell position will be triggered when Ask >= order price. Sell order and Stop Loss for Buy position will be triggered when Bid <= order price.
Opposite 1 Opposite method uses opposite price for order triggering. Buy order and Stop Loss for Sell position will be triggered when Bid >= order price. Sell order and Stop Loss for Buy position will be triggered when Ask <= order price.
DoubleTrade 2 Uses default prices for order triggering, but waits for additional confirmation - two consecutive prices should meet criteria to trigger order. Buy order and Stop Loss for Sell position will be triggered when two consecutive Ask prices >= order price. Sell order and Stop Loss for Buy position will be triggered when two consecutive Bid prices <= order price.
DoubleOpposite 3 Uses opposite prices for order triggering, and waits for additional confirmation - two consecutive prices should meet criteria to trigger order. Buy order and Stop Loss for Sell position will be triggered when two consecutive Bid prices >= order price. Sell order and Stop Loss for Buy position will be triggered when two consecutive Ask prices <= order price.