Exemplo n.º 1
0
        protected override void OnBar()
        {
            double middle = (bb.Top.LastValue + bb.Bottom.LastValue) / 2;

            // Cloture si les prix repassent le milieu de la bande de bollinger
            if (MarketSeries.isCandleOver(1, middle))
            {
                this.closeAllPositions(_instanceLabel);
            }

            TradeType?tradeType = signal();

            if (tradeType.HasValue)
            {
                if (tradeType.isBuy())
                {
                    this.closeAllSellPositions(_instanceLabel);

                    if (this.existBuyPositions(_instanceLabel))
                    {
                        return;
                    }
                }
                else
                {
                    this.closeAllBuyPositions(_instanceLabel);

                    if (this.existSellPositions(_instanceLabel))
                    {
                        return;
                    }
                }

                ExecuteMarketOrder(tradeType.Value, Symbol, Volume, _instanceLabel);
            }
        }