Exemplo n.º 1
0
        //Execute rule logic
        //Place Sell Limit orders when notified by OnOpenForTrading rule
        override protected bool ExcuteRuleLogic(Niffle message)
        {
            if (IsTickMessageEmpty(message))
            {
                return(false);
            }
            if (EntryPipsFromTradeOpenPrice == 0.0)
            {
                return(false);                                     //trigger points should be set when initialised
            }
            if (OpenPrice == 0.0)
            {
                return(false);                  //Open price should be set once activated
            }
            double EntryPrice = TradeUtils.AddPipsToPrice(OpenPrice, EntryPipsFromTradeOpenPrice);

            for (int orderNumber = 1; orderNumber <= NumberOfOrders; orderNumber++)
            {
                TradePublisher.PlaceSellLimit(SymbolCode,
                                              StrategyId + "-" + orderNumber,
                                              TradeUtils.CalculateNextOrderVolume(orderNumber),
                                              TradeUtils.AddPipsToPrice(EntryPrice, TradeUtils.CalculateNextEntryPips(orderNumber)));
            }

            //Set inactive if only executing once
            SetActiveState(false);

            //return true to publish a success Service Notify message
            return(true);
        }