|
| 1 | +-- |
| 2 | +-- Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +-- you may not use this file except in compliance with the License. |
| 4 | +-- You may obtain a copy of the License at |
| 5 | +-- |
| 6 | +-- http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +-- |
| 8 | +-- Unless required by applicable law or agreed to in writing, software |
| 9 | +-- distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +-- See the License for the specific language governing permissions and |
| 12 | +-- limitations under the License. |
| 13 | +-- |
| 14 | +-- https://github.com/Roffild/qlua |
| 15 | +-- |
| 16 | + |
| 17 | +Settings = { |
| 18 | + Name = "Levels_Roffild", |
| 19 | + Step = 0, |
| 20 | + line = {} |
| 21 | +} |
| 22 | + |
| 23 | +LINES = 10 |
| 24 | + |
| 25 | +for x = 1, LINES, 1 do |
| 26 | + Settings.line[x] = { |
| 27 | + Name = "Line" .. tostring(x), |
| 28 | + Type = TYPE_POINT, |
| 29 | + Color = RGB(55, 55, 55), |
| 30 | + Width = 2 |
| 31 | + } |
| 32 | +end |
| 33 | + |
| 34 | +local rd = require("roffild") |
| 35 | + |
| 36 | +function Init() |
| 37 | + LINES = #Settings.line |
| 38 | + return LINES |
| 39 | +end |
| 40 | + |
| 41 | +function OnCalculate(index) |
| 42 | + local start = O(index) |
| 43 | + if start == nil then |
| 44 | + return nil |
| 45 | + end |
| 46 | + if MINSTEP == nil then |
| 47 | + local info = getDataSourceInfo() |
| 48 | + local secinfo = getSecurityInfo(info.class_code, info.sec_code) |
| 49 | + MINSTEP = secinfo.min_price_step |
| 50 | + STEP = Settings.Step |
| 51 | + if STEP <= 0 then |
| 52 | + if secinfo.base_active_seccode == "SBRF" then |
| 53 | + STEP = 500 |
| 54 | + elseif secinfo.base_active_seccode == "GAZR" then |
| 55 | + STEP = 500 |
| 56 | + elseif secinfo.base_active_seccode == "VTBR" then |
| 57 | + STEP = 50 |
| 58 | + elseif secinfo.base_active_seccode == "Eu" then |
| 59 | + STEP = 250 |
| 60 | + elseif secinfo.base_active_seccode == "ED" then |
| 61 | + STEP = 25 |
| 62 | + elseif secinfo.base_active_seccode == "SILV" then |
| 63 | + STEP = 10 |
| 64 | + else |
| 65 | + STEP = 100 |
| 66 | + end |
| 67 | + end |
| 68 | + FIRST = (rd.round(LINES / 2) + 1) * STEP * MINSTEP |
| 69 | + end |
| 70 | + local result = {} |
| 71 | + start = start - ((math.tointeger(rd.round(start / MINSTEP)) % STEP) * MINSTEP) + FIRST |
| 72 | + for x = 1, LINES, 1 do |
| 73 | + table.insert(result, start - (x * STEP * MINSTEP)) |
| 74 | + end |
| 75 | + return table.unpack(result) |
| 76 | +end |
0 commit comments