Почему-то тестер закрывает по Stop Out при уровне маржинальности больше установленной

 

День добрый...

 Помогите разобраться со проблемой закрытия позиция при тестировании советника - закрывает при 99,5% - хотя MarginStop = 30 - в чем может быть дело...

2016.01.09 21:50:37.158 SBER,H4: 2802 ticks (5 bars) generated in 0:00:17.703 (total bars in history 761, total time 0:00:18.234)

2016.01.09 21:50:37.158 stop out occurred on 0% of testing interval

2016.01.09 21:50:37.144 final balance 98587.60 RUR

2016.01.09 21:50:37.144 2015.01.09 13:00:20   order performed buy 107.00 at 65.00 [#3 buy 107.00 SBER at 65.00]

2016.01.09 21:50:37.144 2015.01.09 13:00:20   deal performed [#3 buy 107.00 SBER at 65.00]

2016.01.09 21:50:37.144 2015.01.09 13:00:20   deal #3 buy 107.00 SBER at 65.00 done (based on order #3)

2016.01.09 21:50:37.144 2015.01.09 13:00:20   position stop out triggered at 99.50% [sell 107.00 SBER 63.68 sl: 65.27 tp: 59.86]

2016.01.09 21:50:35.651 2015.01.09 12:00:00   Balance=100000.0 Credit=0.0 Profit=0.0 Equity=31862.4 Margin=29980.54 FreeMargin=1881.86 MarginLevel=106.2769383073153 MarginCall=50.0 MarginStopOut=30.0 Leverage=0

2016.01.09 21:50:35.651 2015.01.09 12:00:00   Alert: Ордер Buy успешно помещен, тикет ордера #:2!!

2016.01.09 21:50:35.651 2015.01.09 12:00:00   CTrade::OrderSend: exchange sell 107.00 SBER sl: 65.27 tp: 59.86 [done]

2016.01.09 21:50:35.648 2015.01.09 12:00:00   order performed sell 107.00 at 63.68 [#2 sell 107.00 SBER at 63.68]

2016.01.09 21:50:35.648 2015.01.09 12:00:00   deal performed [#2 sell 107.00 SBER at 63.68]

2016.01.09 21:50:35.648 2015.01.09 12:00:00   deal #2 sell 107.00 SBER at 63.68 done (based on order #2)

2016.01.09 21:50:35.648 2015.01.09 12:00:00   exchange sell 107.00 SBER at 63.68 sl: 65.27 tp: 59.86 (63.68 / 63.69 / 63.68)

2016.01.09 21:50:35.648 2015.01.09 12:00:00   MaxLotCheck = 356.0 Lot = 107 

 

Открывают позицию, проверяю максимальное количество, а открываю short только на свои с учетом стоп-лосса

 

        Lot = MathFloor((1-account.MarginStopOut()/100)*(account.Balance()+account.Profit())/(latest_price.bid*(1+StopLoss/100)*symbol_info.ContractSize()));
        Print("MaxLotCheck = ", account.MaxLotCheck( _Symbol, ORDER_TYPE_SELL, symbol_info.NormalizePrice(latest_price.bid * (1+StopLoss/100))), " Lot = ",Lot);
        Trade.Sell(Lot, _Symbol, symbol_info.NormalizePrice(latest_price.bid), symbol_info.NormalizePrice(latest_price.bid * (1+StopLoss/100)), 
               symbol_info.NormalizePrice(latest_price.bid * (1-TakeProfit/100)),"Sell...");