<?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>Sat, 02 May 2026 14:29:16 +0300</pubDate>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37453/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<br />====quote====<br /><a class="blog-p-user-name" id="bp_xD3FM4tP" href="/user/12990/" bx-tooltip-user-id="12990">Sorokin</a> написал:<br />Нашел ошибку. Но &nbsp;теперь attempt to perform arithmetic on upvalue 'Trade_B...<br />=============<br />Значит не правильно исправили ошибку.<br /><br />Рекомендуем еще раз внимательней проверить что и как происходит с переменной Trade_B <br />
			<i>15.04.2019 15:02:11, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37453/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37453/topic4438/</guid>
			<pubDate>Mon, 15 Apr 2019 15:02:11 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37418/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Прикольно... разместил какой-то скрипт, и парни из поддержки тебе его отлаживают :) <br />
			<i>13.04.2019 06:01:09, Imersio Arrigo.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37418/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37418/topic4438/</guid>
			<pubDate>Sat, 13 Apr 2019 06:01:09 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37411/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Нашел ошибку. Но &nbsp;теперь attempt to perform arithmetic on upvalue 'Trade_B... <br />
			<i>12.04.2019 15:43:23, Sorokin.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37411/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37411/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 15:43:23 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37405/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<br />====quote====<br /><a class="blog-p-user-name" id="bp_ZQqFj0OE" href="/user/12990/" bx-tooltip-user-id="12990">Sorokin</a> написал:<br />Но есть же параметр выше в коде function OnTrade(trade)<br />=============<br /><br />Значит колбек OnTrade не срабатывает до обращения к Trade_B+50 &nbsp;<br />Кроме того в колбеке какая-то проверка. <br /><br />таким образом пока не будет сделки удовлетворяющей условию, колбек не сработает, &nbsp;а пока он не сработает ,переменная Trade_B не будет существовать <br />
			<i>12.04.2019 14:39:15, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37405/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37405/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 14:39:15 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37404/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Да, я понял что он ругается на отсутствие значения Trade_B<br /><br />Но есть же параметр выше в коде <br /><br />function OnTrade(trade)<br />if trade.order_num == Num_B_Order then<br />Trade_B = trade.price<br />end<br />end <br />
			<i>12.04.2019 14:30:38, Sorokin.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37404/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37404/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 14:30:38 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37403/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<br />====quote====<br /><a class="blog-p-user-name" id="bp_bb8WjvIX" href="/user/12990/" bx-tooltip-user-id="12990">Sorokin</a> написал:<br />пишет &nbsp;"attempt to perform arithmetic on upvalue 'Trade_B' (a nil value)".....не нравится условие Trade_B+50 &nbsp; <br />=============<br /><br />ошибка означает что переменная не задана.<br /><br />простой пример покажет ошибку:<br /><br />X = Y + 1<br /><br />чему будет равно X? &nbsp;никто не знает т.к. Y неизвестно. Вот и ошибка у Вас говорит о том же, что значение Trade_B неизвестно.<br /><br />Вот если написать например так:<br />Y = 0<br />X = Y + 1<br /><br />то сразу понятно что X будет равен 1 и ошибки не будет.<br />Вот и Вам надо задать значение для Trade_B <br />
			<i>12.04.2019 14:26:33, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37403/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37403/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 14:26:33 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37400/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Поместил внутрь. Вот так. &nbsp; &nbsp;Скрипт запускается и работает. &nbsp;Заявку отправляет, спасибо большое), но стоп и тейк так и не работают...<br /><br />пишет &nbsp;&quot;attempt to perform arithmetic on upvalue 'Trade_B' (a nil value)&quot;.....<br /><br />не нравится условие Trade_B+50 &nbsp; <br /><br />Почему?<br /><br /><br />while stopped == false do<br />local Date = getInfoParam(&quot;TRADEDATE&quot;)<br />local Time = getInfoParam(&quot;SERVERTIME&quot;)<br /><br />local DataCandles = getNumCandles(&quot;sberprice&quot;)<br />local sberprice, sberN, sberName = getCandlesByIndex(&quot;sberprice&quot;, 0, 0, DataCandles)<br /><br />local Day = sberprice&#91;sberN-1&#93;.datetime.day<br />local Hour = sberprice&#91;sberN-1&#93;.datetime.hour<br />local Minute = sberprice&#91;sberN-1&#93;.datetime.min<br />local Open = sberprice&#91;sberN-1&#93;.open<br />local Close = sberprice&#91;sberN-1&#93;.close<br />local High = sberprice&#91;sberN-1&#93;.high<br />local Low = sberprice&#91;sberN-1&#93;.low<br /><br />local Open2 = sberprice&#91;sberN-2&#93;.open<br />local Close2 = sberprice&#91;sberN-2&#93;.close<br />local High2 = sberprice&#91;sberN-2&#93;.high<br />local Low2 = sberprice&#91;sberN-2&#93;.low<br /><br />local Open3 = sberprice&#91;sberN-3&#93;.open<br />local Close3 = sberprice&#91;sberN-3&#93;.close<br />local High3 = sberprice&#91;sberN-3&#93;.high<br />local Low3 = sberprice&#91;sberN-3&#93;.low<br /><br /><br />SetCell(TableData, 1,11, tostring(Date))<br />SetCell(TableData, 1,10, tostring(Time))<br />SetCell(TableData, 1, 3, tostring(Day))<br />SetCell(TableData, 1, 4, tostring(Hour))<br />SetCell(TableData, 1, 5, tostring(Minute))<br />SetCell(TableData, 1, 6, tostring(Open-Open%1))<br />SetCell(TableData, 1, 7, tostring(Close-Close%1))<br />SetCell(TableData, 1, 8, tostring(High-High%1))<br />SetCell(TableData, 1, 9, tostring(Low-Low%1))<br /><br />SetCell(TableData, 2, 6, tostring(Open2-Open2%1))<br />SetCell(TableData, 2, 7, tostring(Close2-Close2%1))<br />SetCell(TableData, 2, 8, tostring(High2-High2%1))<br />SetCell(TableData, 2, 9, tostring(Low2-Low2%1))<br /><br />SetCell(TableData, 3, 6, tostring(Open3-Open3%1))<br />SetCell(TableData, 3, 7, tostring(Close3-Close3%1))<br />SetCell(TableData, 3, 8, tostring(High3-High3%1))<br />SetCell(TableData, 3, 9, tostring(Low3-Low3%1))<br /><br />if not(in_trade) then<br />if Close &gt; Close2 and Close2 &gt; Close3 then<br />Trade()<br />end<br />end<br /><br />end <br />
			<i>12.04.2019 13:47:00, Sorokin.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37400/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37400/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 13:47:00 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37398/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<a class="blog-p-user-name" id="bp_LzJDRlYZ" href="/user/12990/" bx-tooltip-user-id="12990">Sorokin</a>, <br /><br />У Вас под составлен так что функция Trade() вызывается только после выхода из цикла "while stopped == false do" может быть в этом проблема?<br />Попробуйте переместить во внутрь цикла <br />
			<i>12.04.2019 09:56:32, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37398/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37398/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 09:56:32 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37397/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			&nbsp;Условие скрипта думаю понятно...хотя уточню, что именно хотел реализовать. <br /><br />&quot;Если закрытие свечи больше чем предыдущий, а закрытие предыдущей больше более ранней, &nbsp;и нет открытых позиций, то отправляется заявка на покупку. Одновременно выставляется стоп-лосс и тейк-профит. После срабатывания тейка снимается стоп и наоборот.&quot;<br /><br /><br />В ранней версии скрипта делал покупку, но упорно не хотел ставить стоп и тейк. Пока разбирался с причиной и правил скрипт в итоге &quot;добился&quot; что и покупать перестал :( &nbsp;<br />Смотрю, вроде все логично(ну опять таки в моем делитантском понимании), но причину не пойму. &nbsp; <br />
			<i>12.04.2019 07:36:10, Sorokin.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37397/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37397/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 07:36:10 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37395/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			<br />====quote====<br /><a class="blog-p-user-name" id="bp_UQNZNM03" href="/user/17/" bx-tooltip-user-id="17">Sergey Gorokhov</a> написал:<br />Здравствуйте,<br />Первое что бросается в глаза у цикла while stopped == false do нет завершающего end<br />=============<br />А нет, прошу прощения с этим все в порядке.<br />Уточните подробней, что именно не работает? У нас код не вызывает ошибок. <br />
			<i>12.04.2019 05:09:53, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37395/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37395/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 05:09:53 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37394/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Здравствуйте,<br />Первое что бросается в глаза у цикла while stopped == false do нет завершающего end <br />
			<i>12.04.2019 05:06:26, Sergey Gorokhov.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37394/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37394/topic4438/</guid>
			<pubDate>Fri, 12 Apr 2019 05:06:26 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
		<item>
			<title>Помогите найти ошибку</title>
			<description><![CDATA[<b><a href="http://forum.quik.ru/messages/forum10/message37390/topic4438/">Помогите найти ошибку</a></b> <i>Вам, как экспертам, возможно, не сложно, а я застрял....</i> в форуме <a href="http://forum.quik.ru/forum10/">Программирование на языке Lua</a>. <br />
			Всем привет. Начинаю только изучать язык, написал ( как мог) примитивный скрипт, вроде все правильно, но не работает.....перепроверил много раз не могу понять в чем причина....Посмотрите, пожалуйста, если не трудно. Укажите на ошибки. <br /><br /><br /><br />in_trade = false <br /><br />local stopped = false<br />function OnStop()<br />	stopped = true<br />	return 1000<br />end<br /><br />local ID_B_Order = 100<br />local ID_B_Stop = 200<br />local ID_B_Take = 300<br />local ID_B_StopKill = 200.1<br />local ID_B_TakeKill = 300.1<br />local Status_B_Order<br />local Status_B_Stop<br />local Status_B_Take<br />local Status_B_StopKill<br />local Status_B_takeKill<br />local MSG_B_Order<br />local MSG_B_Stop<br />local MSG_B_Take<br />local MSG_B_StopKill<br />local MSG_B_TakeKill<br />local Num_B_Order<br />local Num_B_Stop<br />local Num_B_Take<br />local State_B_Order<br />local Trade_B<br />local Stop_B_Activ = &quot;NO&quot;<br />local Stop_Kill = &quot;NO&quot;<br />local Take_B_Activ = &quot;NO&quot;<br /><br /><br />function OnTransReply(order)<br />	if order.trans_id == ID_B_Order then<br />	Status_B_Order = order.status<br />	Num_B_Order = order.order_num<br />	MSG_B_Order = order.result.msg<br />	end<br />	if order.trans_id == ID_B_Stop then<br />	Status_B_Stop = order.status<br />	Num_B_Stop = order.oreder_num<br />	MSG_B_Stop = order.result.msg<br />	end<br />	if order.trans_id == ID_B_Take then<br />	Status_B_Take = order.status<br />	Num_B_Take = order.oreder_num<br />	MSG_B_Take = order.result.msg<br />	end<br />	if order.trans_id == ID_B_StopKill then<br />	Status_B_StopKill = order.status<br />	MSG_B_StopKill = order.result.msg<br />	end<br />	if order.trans_id == ID_B_TakeKillKill then<br />	Status_B_takeKill = order.status<br />	MSG_B_TakeKill = order.result.msg<br />	end<br /><br />end<br /><br />function OnOrder(order)<br />	if Num_B_Order == order.order_num then<br />		if bit.band(order.flags, 0x1) == 0 and bit.band(order.flags, 0x2) == 0 then<br />		State_B_Order = &quot;Исполнена&quot;<br />		end<br />	end<br />end<br /><br />function OnTrade(trade)<br />	if trade.order_num == Num_B_Order then<br />		Trade_B = trade.price<br />	end<br />end<br /><br />function OnStopOrder(order)<br />	if Num_B_Stop == order.order_num then<br />		if bit.band(order.flags, 0x1) == 0 and bit.band (order.flags, 0x2) == 0 then<br />			Stop_B_Activ = &quot;YES&quot;<br />		end<br />	end<br />	if Num_B_Take == order.order_num then<br />		if bit.band(order.flags, 0x8000) ~= 0 then<br />			Take_B_Activ = &quot;YES&quot;<br />		end<br />	end<br />end<br /><br /><br />function ResTransaction (ID, Num, Status, MSG, Err)<br />local FileName = &quot;C:\\Lua\\123.txt&quot;<br />local FileOpen = io.open(FileName, &quot;a&quot;)<br />local TradeDate = getInfoParam(&quot;TRADEDATE&quot;)<br />local ServerTime = getInfoParam(&quot;SERVERTIME&quot;)<br />if Status == 3 then<br />	message(&quot;ID: &quot;..ID.. &quot;\nNum: &quot;..Num.. &quot;\nStatus: &quot;..Status.. &quot;\nMSG: &quot;..MSG, 1)<br />	FileOpen:write(&quot;Date: &quot;..TradeDate.. &quot;\tTime: &quot;..ServerTime.. &quot;\tID: &quot;..ID.. &quot;\tNum: &quot;..Num.. &quot;\tStatus &quot;..Status)<br />elseif Status == nil then<br />	message(&quot;Status == nil. ТРАНЗАКЦИЯ &quot;..ID..&quot; НЕ ВЫПОЛНЕНА. &quot;..Err, 1)<br />	FileOpen:write (&quot;Date: &quot;..TradeDate &quot;\tTIME: &quot;..ServerTime.. &quot;\tStatus == nil. ТРАНЗАКЦИЯ &quot;..ID..&quot;НЕ ВЫПОЛНЕНА. &quot;..Err, 1)<br />elseif Status ~=nil then<br />	message(&quot;MSG: &quot;..MSG, 1)<br />	FileOpen:write (&quot;DATE: &quot;..TradeDate.. &quot;\tTIME: &quot;..ServerTime.. &quot;\tMSG: &quot;..MSG.. &quot;\n&quot;)<br />end<br />FileOpen:close()<br />end<br /><br /><br /><br /><br />function main()<br /><br />local TableData = AllocTable() &nbsp; &nbsp; -- будущая таблица робота обработчика<br />AddColumn(TableData, 1, &quot;Параметры&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 2, &quot;Инструмент&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 3, &quot;День&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 4, &quot;Час&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 5, &quot;Минута&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 6, &quot;Открытие&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 7, &quot;Закрытие&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 8, &quot;Максимум&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 9, &quot;Минимум&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 10, &quot;Время&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 11, &quot;Дата&quot;, true, QTABLE_STRING_TYPE, 15)<br />AddColumn(TableData, 12, &quot;Примечание&quot;, true, QTABLE_STRING_TYPE, 15)<br /><br /><br />CreateWindow(TableData)<br />	SetWindowCaption(TableData, &quot;Данные с графика&quot;)<br />	SetWindowPos(TableData, 0,10,900,70)<br />	InsertRow(TableData, -1)<br />	InsertRow(TableData, -2)<br />	InsertRow(TableData, -3)<br /><br />while stopped == false do<br />local Date = getInfoParam(&quot;TRADEDATE&quot;)<br />local Time = getInfoParam(&quot;SERVERTIME&quot;)<br /><br />local DataCandles = getNumCandles(&quot;sberprice&quot;)<br />local sberprice, sberN, sberName = getCandlesByIndex(&quot;sberprice&quot;, 0, 0, DataCandles)<br /><br />local Day = sberprice&#91;sberN-1&#93;.datetime.day<br />local Hour = sberprice&#91;sberN-1&#93;.datetime.hour<br />local Minute = sberprice&#91;sberN-1&#93;.datetime.min<br />local Open = sberprice&#91;sberN-1&#93;.open<br />local Close = sberprice&#91;sberN-1&#93;.close<br />local High = sberprice&#91;sberN-1&#93;.high<br />local Low = sberprice&#91;sberN-1&#93;.low<br /><br />local Open2 = sberprice&#91;sberN-2&#93;.open<br />local Close2 = sberprice&#91;sberN-2&#93;.close<br />local High2 = sberprice&#91;sberN-2&#93;.high<br />local Low2 = sberprice&#91;sberN-2&#93;.low<br /><br />local Open3 = sberprice&#91;sberN-3&#93;.open<br />local Close3 = sberprice&#91;sberN-3&#93;.close<br />local High3 = sberprice&#91;sberN-3&#93;.high<br />local Low3 = sberprice&#91;sberN-3&#93;.low<br /><br /><br />SetCell(TableData, 1,11, tostring(Date))<br />SetCell(TableData, 1,10, tostring(Time))<br />SetCell(TableData, 1, 3, tostring(Day))<br />SetCell(TableData, 1, 4, tostring(Hour))<br />SetCell(TableData, 1, 5, tostring(Minute))<br />SetCell(TableData, 1, 6, tostring(Open-Open%1))<br />SetCell(TableData, 1, 7, tostring(Close-Close%1))<br />SetCell(TableData, 1, 8, tostring(High-High%1))<br />SetCell(TableData, 1, 9, tostring(Low-Low%1))<br /><br />SetCell(TableData, 2, 6, tostring(Open2-Open2%1))<br />SetCell(TableData, 2, 7, tostring(Close2-Close2%1))<br />SetCell(TableData, 2, 8, tostring(High2-High2%1))<br />SetCell(TableData, 2, 9, tostring(Low2-Low2%1))<br /><br />SetCell(TableData, 3, 6, tostring(Open3-Open3%1))<br />SetCell(TableData, 3, 7, tostring(Close3-Close3%1))<br />SetCell(TableData, 3, 8, tostring(High3-High3%1))<br />SetCell(TableData, 3, 9, tostring(Low3-Low3%1))<br />end<br /><br /><br />function Trade()<br />	local Price_Stop<br />	local Price_Take<br />	t = {<br />	&#91;&quot;ACTION&quot;&#93;= &quot;NEW_ORDER&quot;,<br />	&#91;&quot;ACCOUNT&quot;&#93; = &quot;SPBFUT00JUS&quot;,<br />	&#91;&quot;OPERATION&quot;&#93; = &quot;B&quot;,<br />	&#91;&quot;CLASSCODE&quot;&#93; = &quot;SPBFUT&quot;,<br />	&#91;&quot;SECCODE&quot;&#93; =&quot;SRM9&quot;,<br />	&#91;&quot;CLIENT_CODE&quot;&#93; = &quot;21096&quot;,<br />	&#91;&quot;TYPE&quot;&#93;=&quot;M&quot;,<br />	&#91;&quot;PRICE&quot;&#93; = tostring(0),<br />	&#91;&quot;Quantity&quot;&#93; = tostring(1),<br />	&#91;&quot;TRANS_ID&quot;&#93; = tostring(100)}<br />	sleep(5000)<br />	in_trade = true<br />	local Err_Order = sendTransaction(t)<br />	while Status_B_Order == nil and Err_Order == &quot;&quot; do<br />		sleep(100)<br />		end<br />	ResTransaction (ID_B_Order,Num_B_Order, Status_B_Order, MSG_B_Order, Err_Order)<br /><br />if Status_B_Order == 3 then<br />	while State_B_Order ~= &quot;Исполнена&quot; do<br />	sleep(10)<br />	end<br />end<br />if State_B_Order == &quot;Исполнена&quot; then<br />	Price_Stop = Trade_B &lt;= sberprice&#91;sberN-2&#93;.close<br />	local Spread = 100<br />end<br />local StopLimitSell = {<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'ACTION'&#93; = &quot;NEW_STOP_ORDER&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'PRICE'&#93; = tostring(21000),<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'EXPIRY_DATE'&#93; = &quot;GTC&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'STOPPRICE'&#93; = tostring(Price_Stop),<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'STOP_ORDER_KIND'&#93; = &quot;SIMPLE_STOP_ORDER&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'TRANS_ID'&#93; = tostring(ID_B_Stop),<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'CLASSCODE'&#93; = &quot;SPBFUT&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'SECCODE'&#93; = &quot;SRM9&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'ACCOUNT'&#93; = &quot;SPBFUT00JUS&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'CLIENT_CODE'&#93; = &quot;21096&quot;, <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'TYPE'&#93; = &quot;L&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'OPERATION'&#93; = &quot;S&quot;,<br />					 &nbsp; &#91;'CONDITION'&#93; = tostring (4), <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'QUANTITY'&#93; = tostring(1)<br />					 &nbsp; }<br />local Err_Stop = sendTransaction(StopLimitSell)<br />	while Status_B_Stop == nil and Err_Stop == &quot;&quot; do<br />	sleep(100)<br />	end<br />ResTransaction (ID_B_Order,Num_B_Order, Status_B_Order, MSG_B_Order, Err_Stop)<br />Price_Take = Trade_B + 50<br />local TakeLimitSell ={<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'ACTION'&#93; = &quot;NEW_STOP_ORDER&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'PRICE'&#93; = tostring(24000),<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'EXPIRY_DATE'&#93; = &quot;GTC&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'STOPPRICE'&#93; = tostring(Price_Take),<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'STOP_ORDER_KIND'&#93; = &quot;TAKE_PROFIT_STOP_ORDER&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'TRANS_ID'&#93; = tostring(ID_B_Take),<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'CLASSCODE'&#93; = &quot;SPBFUT&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'SECCODE'&#93; = &quot;SRM9&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'ACCOUNT'&#93; = &quot;SPBFUT00JUS&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'CLIENT_CODE'&#93; = &quot;21096&quot;, <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'TYPE'&#93; = &quot;L&quot;,<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'OPERATION'&#93; = &quot;S&quot;,<br />					 &nbsp; &#91;'CONDITION'&#93; = tostring (5), <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#91;'QUANTITY'&#93; = tostring(1)}<br />local Err_Stop = sendTransaction(TakeLimitSell)<br />while Status_B_Stop == nil and Err_Stop == &quot;&quot; do<br />	sleep(100)<br />	end<br />ResTransaction (ID_B_Order,Num_B_Order, Status_B_Order, MSG_B_Order, Err_Take)<br />while stopped == false do<br />	if Stop_B_Activ == &quot;YES&quot; then<br />		local killTake = {<br />			&#91;&quot;ACTION&quot;&#93; = &quot;KILL_STOP_ORDER&quot;,<br />			&#91;&quot;CLASSCODE&quot;&#93; = &quot;SPBFUT&quot;,<br />			&#91;&quot;SECCODE&quot;&#93; = &quot;SRM9&quot;,<br />			&#91;&quot;STOP_ORDER_KEY&quot;&#93; = tostring(Num_B_Take),<br />			&#91;&quot;TRANS_ID&quot;&#93; = tostring(ID_B_TakeKill),<br />			}<br />			local Err_KillTake = sendTransaction(killTake)<br />			while Status_B_TakeKill == nil and Err_KillTake == &quot;&quot; do<br />				sleep(10)<br />			ResTransaction (ID_B_TakeKill, Num_B_Take, Status_B_TakeKill, MSG_B_TakeKill, Err_KillTake)<br />			Stop_B_Activ = &quot;TakeKill&quot;<br />			end<br />			if Take_B_Activ == &quot;YES&quot; and Stop_Kill == &quot;NO&quot; then<br />			killStop = {<br />			&#91;&quot;ACTION&quot;&#93; = &quot;KILL_STOP_ORDER&quot;,<br />			&#91;&quot;CLASSCODE&quot;&#93; = &quot;SPBFUT&quot;,<br />			&#91;&quot;SECCODE&quot;&#93; = &quot;SRM9&quot;,<br />			&#91;&quot;STOP_ORDER_KEY&quot;&#93; = tostring(Num_B_Stop),<br />			&#91;&quot;TRANS_ID&quot;&#93; = tostring(ID_B_StopKill),<br />			}<br />			local Err_KillStop= sendTransaction(killStop)<br />			while Status_B_StopKill == nil and Err_KillStop == &quot;&quot; do<br />				sleep(10)<br />			end<br />			ResTransaction (ID_B_StopKill, Num_B_Stop, Status_B_StopKill, MSG_B_StopKill, Err_KillStop)<br />			Stop_Kill = &quot;YES&quot;<br />			end<br />			sleep(500)<br />	end<br />end<br /><br />end<br /><br />if not(in_trade) then<br />if Close &gt; Close2 and Close2 &gt; Close3 then<br />Trade()<br />end<br />end<br /><br />end -- Закрытие основной функции <br />
			<i>11.04.2019 13:42:08, Sorokin.</i>]]></description>
			<link>http://forum.quik.ru/messages/forum10/message37390/topic4438/</link>
			<guid>http://forum.quik.ru/messages/forum10/message37390/topic4438/</guid>
			<pubDate>Thu, 11 Apr 2019 13:42:08 +0300</pubDate>
			<category>Программирование на языке Lua</category>
		</item>
	</channel>
</rss>
