При переборе циклом for выдвет ошибку attempt to index a nil value. В чем ошибка функции?
Код |
---|
function Count_Contracts_By_Price(price, sell_or_buy_order) local qty_opders = 0 for f = 0, getNumberOf("orders") - 1 do local order_info = getItem("orders", f) if order_info.sec_code == Emit and order_info.account == MyAccount and CheckBit(order_info.flags, 0) == 1 and (order_info.brokerref == "LimitLevels") then if (order_info.price == price) and (CheckBit(order_info.flags, 2) == 1) and (sell_or_buy_order == "Sell") then qty_opders = qty_opders + order_info.qty elseif (order_info.price == price) and (CheckBit(order_info.flags, 2) ~= 1) and (sell_or_buy_order == "Buy") then qty_opders = qty_opders + order_info.qty end end end return qty_opders end |