Exemple #1
0
        public static Tuple <Order, StopLossOrder, TakeProfitOrder> OrderTriple(Market CurrentMarket, TradeAction Action, int ContractId, int StrategyId, PositiveInteger Quantity,
                                                                                decimal TakeProfit, decimal StopLoss, bool TrailingStopLoss)
        {
            decimal         desiredPrice = (Action == TradeAction.Buy ? CurrentMarket.Ask : CurrentMarket.Bid);
            Order           entry        = MarketOrder(CurrentMarket.Timestamp, Action, ContractId, StrategyId, Quantity, desiredPrice);
            StopLossOrder   stoploss     = new StopLossOrder(entry, StopLoss, TrailingStopLoss);
            TakeProfitOrder takeprofit   = new TakeProfitOrder(entry, TakeProfit);

            return(new Tuple <Order, StopLossOrder, TakeProfitOrder>(entry, stoploss, takeprofit));
        }
Exemple #2
0
        public static Order TestExitOrders(Market CurrentMarket, StopLossOrder StopLossOrder, TakeProfitOrder TakeProfitOrder)
        {
            if (StopLossOrder != null && StopLossOrder.Test(CurrentMarket))
            {
                return(StopLossOrder);
            }

            if (TakeProfitOrder != null && TakeProfitOrder.Test(CurrentMarket))
            {
                return(TakeProfitOrder);
            }

            return(null);
        }