<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Форум QUIK [тема: создание индикаторов]</title>
		<link>http://forum.quik.ru</link>
		<description>Новое в теме создание индикаторов форума  на сайте Форум QUIK [forum.quik.ru]</description>
		<language>ru</language>
		<docs>http://backend.userland.com/rss2</docs>
		<pubDate>Tue, 07 Apr 2026 23:56:48 +0300</pubDate>
		<item>
			<title>создание индикаторов</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message26002/topic2970/">создание индикаторов</a></b> <i>Создание индикатора по предложенному образцу у Вас</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<a class="blog-p-user-name" id="bp_HEJe9Mkt" href="/user/6080/" bx-tooltip-user-id="6080">Evgeny Grizli</a>, <br /><br />Еще раз. Основной инструмент индикатора это тот <B>на график</B> которого Вы добавляете индикатор. И не важно в какой области окна он располагается.<br />При добавлении индикатора Вы сами явно его указываете в окне "Добавление графика" пункт "Источник данных" <br />
			<i>29.07.2017 03:35:25, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message26002/topic2970/</link>
			<guid>http://forum.quik.ru/messages/forum10/message26002/topic2970/</guid>
			<pubDate>Sat, 29 Jul 2017 03:35:25 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>создание индикаторов</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message25999/topic2970/">создание индикаторов</a></b> <i>Создание индикатора по предложенному образцу у Вас</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			я немного его изменил начало вот такое: <br />--------------------------------------------------------------------<br />--<br />-- Построение спреда по нескольким инструментам:<br />-- spread := k * price(security) + k1 * price(tag1) + k2 * price(tag2) + a.<br />-- Можно добавлять дополнительные инструменты, модифицируя код индикатора.<br />--<br /><br />Settings = {<br /> &nbsp; &nbsp;Name = &quot;SpreadIndicator_1&quot;,<br /> &nbsp; &nbsp;k = 1, -- коэффициент, с которым учитывается цена основного инструмента<br /> &nbsp; &nbsp;tag1 = &quot;SberB60&quot;, -- метка графика, откуда берётся цена дополнительного инструмента 1<br /> &nbsp; &nbsp;tag2 = &quot;SberBD&quot;, -- метка графика, откуда берётся цена дополнительного инструмента 2<br /> &nbsp; &nbsp;k1 = -2, -- коэффициент, с которым учитывается цена дополнительного инструмента 1<br /> &nbsp; &nbsp;k2 = -3, -- коэффициент, с которым учитывается цена дополнительного инструмента 2<br /> &nbsp; &nbsp;a = 0, -- свободный член<br /> &nbsp; &nbsp;line = { { Name = &quot;Spread_1&quot;, Color = RGB(0, 0, 255), Type = TYPE_LINE, Width = 1, } }<br />}<br /><br />function Init()<br /> &nbsp; &nbsp;return 1<br />end<br />---------------------------------------------------------<br />далее не стал писать суть вот в чём:<br />Как видите дополнительные графики это 60 мин &quot;SberB60&quot; и второй Дневной &quot;SberBD&quot;, в отдельном окне первого графика 5 минутки ниже окно я размещаю этот индикатор. Значит основным считается График 5 минутки ? Правильно я понял? <br />
			<i>28.07.2017 17:22:41, Evgeny Grizli.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message25999/topic2970/</link>
			<guid>http://forum.quik.ru/messages/forum10/message25999/topic2970/</guid>
			<pubDate>Fri, 28 Jul 2017 17:22:41 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>создание индикаторов</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message25997/topic2970/">создание индикаторов</a></b> <i>Создание индикатора по предложенному образцу у Вас</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<a class="blog-p-user-name" id="bp_7xwaiJqu" href="/user/6080/" bx-tooltip-user-id="6080">Evgeny Grizli</a>, <br />Это тот инструмент, на график которого Вы добавили индикатор. <br />
			<i>28.07.2017 17:17:32, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message25997/topic2970/</link>
			<guid>http://forum.quik.ru/messages/forum10/message25997/topic2970/</guid>
			<pubDate>Fri, 28 Jul 2017 17:17:32 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>создание индикаторов</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message25996/topic2970/">создание индикаторов</a></b> <i>Создание индикатора по предложенному образцу у Вас</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Точно! Появился такой индикатор! Спасибо!<br />есть один уточняющий вопрос: вот - &quot;price(security)&quot; или ещё вот так: &quot;local securityPrice = C(index) &quot; это основной инструмент? какой? <br />
			<i>28.07.2017 16:54:18, Evgeny Grizli.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message25996/topic2970/</link>
			<guid>http://forum.quik.ru/messages/forum10/message25996/topic2970/</guid>
			<pubDate>Fri, 28 Jul 2017 16:54:18 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>создание индикаторов</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message25988/topic2970/">создание индикаторов</a></b> <i>Создание индикатора по предложенному образцу у Вас</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Здравствуйте,<br />Как Вы запускаете скрипт?<br />Скорее всего причина в том что Вы его запускаете как обычный Lua скрипт через меню.<br />В то время как "индикаторы" не предназначены для такого запуска, их следует добавлять в спец папку LuaIndicators и после этого индикатор появится в списке индикаторов при добавлении на график. <br />Об этом сказано в документации, см глава "Индикаторы технического анализа" - "Общие сведения" <br />
			<i>28.07.2017 03:10:35, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message25988/topic2970/</link>
			<guid>http://forum.quik.ru/messages/forum10/message25988/topic2970/</guid>
			<pubDate>Fri, 28 Jul 2017 03:10:35 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>создание индикаторов</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message25987/topic2970/">создание индикаторов</a></b> <i>Создание индикатора по предложенному образцу у Вас</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			указанный пример &nbsp;присутствует в Вашем материале:<br />&quot;Программный комплекс QUIK –<br />фронт-офисная система прямого доступа<br />Создание индикаторов<br />технического анализа<br />с помощью скриптов Lua<br />Инструкция<br />© ARQA Technologies, октябрь 2013&quot; <br />
			<i>27.07.2017 19:00:27, Evgeny Grizli.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message25987/topic2970/</link>
			<guid>http://forum.quik.ru/messages/forum10/message25987/topic2970/</guid>
			<pubDate>Thu, 27 Jul 2017 19:00:27 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>создание индикаторов</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message25986/topic2970/">создание индикаторов</a></b> <i>Создание индикатора по предложенному образцу у Вас</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			примерно так выглядит сообщение:<br /><br />lua: spread_ind_1.lua:15: attempt to call global 'RGB' (a nil value)<br />stack traceback:<br />	spread_ind_1.lua:15: in main chunk<br />	&#91;C&#93;: in ? <br />
			<i>27.07.2017 18:58:49, Evgeny Grizli.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message25986/topic2970/</link>
			<guid>http://forum.quik.ru/messages/forum10/message25986/topic2970/</guid>
			<pubDate>Thu, 27 Jul 2017 18:58:49 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>создание индикаторов</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message25985/topic2970/">создание индикаторов</a></b> <i>Создание индикатора по предложенному образцу у Вас</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			вот такой пример:<br />--<br />-- Построение спреда по нескольким инструментам:<br />-- spread := k * price(security) + k1 * price(tag1) + k2 * price(tag2) + a.<br />-- Можно добавлять дополнительные инструменты, модифицируя код индикатора.<br />--<br /><br />Settings = {<br /> &nbsp; &nbsp;Name = &quot;SpreadIndicator&quot;,<br /> &nbsp; &nbsp;k = 1, -- коэффициент, с которым учитывается цена основного инструмента<br /> &nbsp; &nbsp;tag1 = &quot;SberB&quot;, -- метка графика, откуда берётся цена дополнительного инструмента 1<br /> &nbsp; &nbsp;tag2 = &quot;SberB60&quot;, -- метка графика, откуда берётся цена дополнительного инструмента 2<br /> &nbsp; &nbsp;k1 = -5, -- коэффициент, с которым учитывается цена дополнительного инструмента 1<br /> &nbsp; &nbsp;k2 = -5, -- коэффициент, с которым учитывается цена дополнительного инструмента 2<br /> &nbsp; &nbsp;a = 0, -- свободный член<br /> &nbsp; &nbsp;line = { { Name = &quot;Spread&quot;, Color = RGB(0, 0, 255), Type = TYPE_LINE, Width = 1, } }<br />}<br /><br />function Init()<br /> &nbsp; &nbsp;return 1<br />end<br /><br />local function getTimeCode(dt)<br /> &nbsp; &nbsp;return (dt.year * 10000 + dt.month * 100 + dt.day) * 1000000 + (dt.hour * 10000 + dt.min * 100 + dt.sec)<br />end<br /><br />--- Найти свечу, относящуюся к заданному времени или предшествующую ему, если для заданного времени нет свечи.<br />-- @param tag строковый идентификатор графика или индикатора<br />-- @param timeCode метка времени в формате yyyymmddhhmmss<br />-- @return искомая свеча или nil, если свеча не найдена.<br />local function getCandleByTimeCode(tag, timeCode)<br /> &nbsp; &nbsp;local numCandles = getNumCandles(tag)<br /> &nbsp; &nbsp;if numCandles &lt; 2 then<br /> &nbsp; &nbsp; &nbsp; &nbsp;return nil<br /> &nbsp; &nbsp;end<br /> &nbsp; &nbsp;local lastCandle, n, _ = getCandlesByIndex(tag, 0, numCandles - 1, 1)<br /> &nbsp; &nbsp;if n ~= 1 then<br /> &nbsp; &nbsp; &nbsp; &nbsp;return nil<br /> &nbsp; &nbsp;end<br /> &nbsp; &nbsp;lastCandle = lastCandle&#91;0&#93;<br /> &nbsp; &nbsp;if getTimeCode(lastCandle.datetime) &lt;= timeCode then<br /> &nbsp; &nbsp; &nbsp; &nbsp;return lastCandle<br /> &nbsp; &nbsp;end<br /> &nbsp; &nbsp;local b = numCandles - 1<br /> &nbsp; &nbsp;local a = b - 1<br /> &nbsp; &nbsp;local candle<br /> &nbsp; &nbsp;while true do<br /> &nbsp; &nbsp; &nbsp; &nbsp;local firstCandle, n, _ = getCandlesByIndex(tag, 0, a, 1)<br /> &nbsp; &nbsp; &nbsp; &nbsp;if n ~= 1 then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return nil<br /> &nbsp; &nbsp; &nbsp; &nbsp;end<br /> &nbsp; &nbsp; &nbsp; &nbsp;firstCandle = firstCandle&#91;0&#93;<br /> &nbsp; &nbsp; &nbsp; &nbsp;local firstTimeCode = getTimeCode(firstCandle.datetime)<br /> &nbsp; &nbsp; &nbsp; &nbsp;if firstTimeCode == timeCode then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return firstCandle<br /> &nbsp; &nbsp; &nbsp; &nbsp;elseif firstTimeCode &lt; timeCode then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;candle = firstCandle<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break<br /> &nbsp; &nbsp; &nbsp; &nbsp;elseif a == 0 then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return nil<br /> &nbsp; &nbsp; &nbsp; &nbsp;else<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a = math.max(0, 2 * a - b)<br /> &nbsp; &nbsp; &nbsp; &nbsp;end<br /> &nbsp; &nbsp;end<br /> &nbsp; &nbsp;while true do<br /> &nbsp; &nbsp; &nbsp; &nbsp;local c = math.floor((a + b) / 2)<br /> &nbsp; &nbsp; &nbsp; &nbsp;if c == a then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return candle<br /> &nbsp; &nbsp; &nbsp; &nbsp;else<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;local middleCandle, n, _ = getCandlesByIndex(tag, 0, c, 1)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if n ~= 1 then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return nil<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;middleCandle = middleCandle&#91;0&#93;<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;local middleTimeCode = getTimeCode(middleCandle.datetime)<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if middleTimeCode == timeCode then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return middleCandle<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;elseif middleTimeCode &lt; timeCode then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a, candle = c, middleCandle<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;b = c<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br /> &nbsp; &nbsp; &nbsp; &nbsp;end<br /> &nbsp; &nbsp;end<br />end<br /><br />--- Вычислить спред.<br />-- @param index номер свечи на графике<br />-- @return значение спреда или nil, если оно неопределено<br />local function getSpread(index)<br /> &nbsp; &nbsp;local timeCode = getTimeCode(T(index))<br /> &nbsp; &nbsp;local securityPrice = C(index)<br /> &nbsp; &nbsp;if securityPrice == nil then<br /> &nbsp; &nbsp; &nbsp; &nbsp;return nil<br /> &nbsp; &nbsp;end<br /> &nbsp; &nbsp;-- Получение свечей дополнительных инструментов<br /> &nbsp; &nbsp;local candle1 = getCandleByTimeCode(Settings.tag1, timeCode)<br /> &nbsp; &nbsp;local candle2 = getCandleByTimeCode(Settings.tag2, timeCode)<br /> &nbsp; &nbsp;if candle1 == nil or candle2 == nil then<br /> &nbsp; &nbsp; &nbsp; &nbsp;return nil<br /> &nbsp; &nbsp;end<br /> &nbsp; &nbsp;-- Получение цен дополнительных инструментов<br /> &nbsp; &nbsp;local price1 = candle1.close<br /> &nbsp; &nbsp;local price2 = candle2.close<br /> &nbsp; &nbsp;if price1 == nil or price2 == nil then<br /> &nbsp; &nbsp; &nbsp; &nbsp;return nil<br /> &nbsp; &nbsp;end<br /> &nbsp; &nbsp;-- Вычисление спреда<br /> &nbsp; &nbsp;local spread = Settings.k * securityPrice<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ Settings.k1 * price1<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ Settings.k2 * price2<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ Settings.a<br /> &nbsp; &nbsp;return spread<br />end<br /><br />function OnCalculate(index)<br /> &nbsp; &nbsp;if index &gt; 1 then<br /> &nbsp; &nbsp; &nbsp; &nbsp;local spread = getSpread(index - 1)<br /> &nbsp; &nbsp; &nbsp; &nbsp;if spread then<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetValue(index - 1, 0, spread)<br /> &nbsp; &nbsp; &nbsp; &nbsp;end<br /> &nbsp; &nbsp;end<br /> &nbsp; &nbsp;return getSpread(index)<br />end<br />---------------------------------------------------------------<br />Вызывает ошибку по оператору &quot;Color&quot; это в 15 строчке. Пожалуйста про комментируйте. Почему ошибка? &nbsp; <br />
			<i>27.07.2017 18:57:43, Evgeny Grizli.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message25985/topic2970/</link>
			<guid>http://forum.quik.ru/messages/forum10/message25985/topic2970/</guid>
			<pubDate>Thu, 27 Jul 2017 18:57:43 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
	</channel>
</rss>
