Ejemplo n.º 1
0
        // Place Sell Orders
        protected void placeSellOrders()
        {
            //Place Sell Limit Orders
            for (int OrderCount = 0; OrderCount < NumberOfPositions - 1; OrderCount++)
            {
                try
                {
                    tradeData data = new tradeData
                    {
                        tradeType      = TradeType.Sell,
                        symbol         = Symbol,
                        volume         = SetVolumeDesc(OrderCount),
                        entryPrice     = 0,
                        label          = _botId + "-" + getTimeStamp() + _marketTimeInfo.market + "-#" + _orderCountLabel,
                        stopLossPips   = CalcStopLoss(OrderCount, NumberOfPositions, false),
                        takeProfitPips = calcTakeProfit(OrderCount)
                    };
                    if (data == null)
                    {
                        continue;
                    }

                    //Place Market Orders immediately
                    ExecuteMarketOrderAsync(data.tradeType, data.symbol, data.volume, data.label + "X", data.stopLossPips, data.takeProfitPips, OnPlaceTradeOperationComplete);
                    _orderCountLabel++;
                } catch (Exception e)
                {
                    Print("Failed to place Sell Limit Order: " + e.Message);
                }
            }
            if (_orderCountLabel > 0)
            {
                _positionsRequested = true;
            }
        }
Ejemplo n.º 2
0
        // Place Sell Limit Orders
        protected void placeSellLimitOrders()
        {
            //Place Sell Limit Orders
            int OrderCount = 0;

            for (; OrderCount < NumberOfSellLimitOrders - 1; OrderCount++)
            {
                try
                {
                    tradeData data = new tradeData
                    {
                        tradeType      = TradeType.Sell,
                        symbol         = Symbol,
                        volume         = SetVolumeAsc(OrderCount),
                        entryPrice     = calcSellEntryPrice(OrderCount),
                        label          = _botId + "-" + getTimeStamp() + _marketTimeInfo.market + "-#" + OrderCount,
                        stopLossPips   = CalcStopLoss(OrderCount, NumberOfSellLimitOrders, true),
                        takeProfitPips = calcTakeProfit(OrderCount)
                    };
                    if (data == null)
                    {
                        continue;
                    }

                    //Check that entry price is valid
                    if (data.entryPrice > Symbol.Ask)
                    {
                        PlaceLimitOrderAsync(data.tradeType, data.symbol, data.volume, data.entryPrice, data.label + "O", data.stopLossPips, data.takeProfitPips, OnPlaceOrderOperationComplete);
                    }
                    else
                    {
                        //Tick price has 'jumped' - therefore avoid placing all PendingOrders by re-calculating the OrderCount to the equivelant entry point.
                        OrderCount = calculateNewOrderCount(NumberOfSellLimitOrders, OrderCount, Symbol.Ask);
                        ExecuteMarketOrderAsync(data.tradeType, data.symbol, data.volume, data.label + "OX", data.stopLossPips, data.takeProfitPips, OnPlaceOrderOperationComplete);
                    }
                } catch (Exception e)
                {
                    Print("Failed to place Sell Limit Order: " + e.Message);
                }
            }
            if (OrderCount > 0)
            {
                _ordersRequested = true;
            }
        }
Ejemplo n.º 3
0
        // Place Sell Limit Orders
        protected void placeSellLimitOrders()
        {
            //Place Sell Limit Orders
            for (int OrderCount = 0; OrderCount < NumberOfOrders; OrderCount++)
            {
                try
                {
                    tradeData data = new tradeData
                    {
                        tradeType      = TradeType.Sell,
                        symbol         = Symbol,
                        volume         = setVolume(OrderCount),
                        entryPrice     = calcSellEntryPrice(OrderCount),
                        label          = _botId + "-" + getTimeStamp() + _swordFishTimeInfo.market + "-SWF#" + OrderCount,
                        stopLossPips   = setPendingOrderStopLossPips(OrderCount, NumberOfOrders),
                        takeProfitPips = TakeProfit * (1 / Symbol.PipSize)
                    };
                    if (data == null)
                    {
                        continue;
                    }

                    //Check that entry price is valid
                    if (data.entryPrice > Symbol.Ask)
                    {
                        PlaceLimitOrderAsync(data.tradeType, data.symbol, data.volume, data.entryPrice, data.label, data.stopLossPips, data.takeProfitPips, onTradeOperationComplete);
                    }
                    else
                    {
                        //Tick price has 'jumped' - therefore avoid placing all PendingOrders by re-calculating the OrderCount to the equivelant entry point.
                        OrderCount = calculateNewOrderCount(OrderCount, Symbol.Ask);
                        ExecuteMarketOrderAsync(data.tradeType, data.symbol, data.volume, data.label + "X", data.stopLossPips, data.takeProfitPips, onTradeOperationComplete);
                    }
                } catch (Exception e)
                {
                    Print("Failed to place Sell Limit Order: " + e.Message);
                }
            }


            //All Sell Limit Orders have been placed
            _ordersPlaced = true;
        }