Exemplo n.º 1
0
        public RecoveryTurn(IActiveTurn activeTurn, RecoveryTurn previousTurn, ZoneLevels zoneLevel, MarketPosition entryPosition, MarketPosition turnPosition, double entryBidPrice, double entryAskPrice, double lotSize, IZoneRecoverySettings settings)
        {
            _settings   = settings;
            _activeTurn = activeTurn;

            _activeTurn.Update(this);

            if (previousTurn == null)
            {
                TurnIndex = 0;
            }
            else
            {
                TurnIndex = previousTurn.TurnIndex + 1;
            }

            ZoneLevels     = zoneLevel;
            _entryPosition = entryPosition;
            PreviousTurn   = previousTurn;

            IsActive   = true;
            Position   = turnPosition;
            EntryPrice = (entryAskPrice + entryBidPrice) / 2;

            _currentPrice   = EntryPrice;
            _commissionRate = _settings.CommissionRate;
            _profitMargin   = _settings.ProfitMarginRate;

            LotSize         = lotSize;
            _pipFactor      = _settings.PipFactor;
            Commission      = lotSize * _commissionRate * _settings.PipFactor;
            Spread          = Math.Abs(entryAskPrice - entryBidPrice);
            MaxSlippageRate = _settings.Slippage;
        }
Exemplo n.º 2
0
        public Session(MarketPosition initPosition, double entryBidPrice, double entryAskPrice, double tradeZoneSize, double zoneRecoverySize, IZoneRecoverySettings settings)
        {
            _settings = settings;

            var midPrice = (entryBidPrice + entryAskPrice) / 2d;

            ZoneLevels = new ZoneLevels(initPosition, midPrice, tradeZoneSize, zoneRecoverySize);
            double profitMargin = tradeZoneSize * _settings.ProfitMarginRate;

            ActivePosition = new RecoveryTurn(this, null, ZoneLevels, initPosition, initPosition, entryBidPrice, entryAskPrice, _settings.InitLotSize, _settings);
        }