<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[QUIK -> DDE &mdash; добавить к цене акции число для стопа и профита.]]></title>
	<link rel="self" href="https://quik2dde.ru/extern.php?action=feed&amp;tid=439&amp;type=atom" />
	<updated>2023-07-05T10:55:05Z</updated>
	<generator>PunBB</generator>
	<id>https://quik2dde.ru/viewtopic.php?id=439</id>
		<entry>
			<title type="html"><![CDATA[Re: добавить к цене акции число для стопа и профита.]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=4262#p4262" />
			<content type="html"><![CDATA[<p>Когда-то давным-давно одни парни пилили библиотеку &quot;вспомогательный функций&quot; для роботов на Lua<br />[url]https://github.com/ahmpro/qllib[/url]</p><p>Хоть библиотека эта &quot;8 лет не обновлялась&quot;, как это модно сейчас говорить, но на самом деле в ней много полезного и все абсолютно актуально. В том числе там точно была вычислялка/форматировалка цен заявок с учетом шага цен и точности цены.<br />Можно или целиком её взять, или, как минимум, подсмотреть/надергать многие полезные кусочки.</p>]]></content>
			<author>
				<name><![CDATA[swerg]]></name>
				<uri>https://quik2dde.ru/profile.php?id=78</uri>
			</author>
			<updated>2023-07-05T10:55:05Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=4262#p4262</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: добавить к цене акции число для стопа и профита.]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=4261#p4261" />
			<content type="html"><![CDATA[<p>Задача решена, землекопа полтора.</p><br /><br /><br /> <br /><br /><br /><br /><p>-- получить параметры последней моей выставленной заявки<br />local n_orders = getNumberOf(&quot;orders&quot;)<br />local last_order = getItem(&quot;orders&quot;, n_orders - 1)<br />-- message(&#039;Номер последней&nbsp; заявки: &#039; ..last_order.order_num.. &#039;Бумаге&nbsp; &nbsp; &#039; ..last_order.sec_code.. &#039; Цена &#039; ..last_order.price.. &#039;Лотов &#039; ..last_order.qty )</p><p>local class_code = &quot;TQBR&quot;<br />local sec_code = last_order.sec_code<br />local lots = math.floor(last_order.qty)<br />local lots1 = tostring(lots)</p><p>-- Получаем минимальный шаг цены (также известен как шаг цены)<br />local price_step = tonumber( getParamEx(class_code, sec_code, &quot;SEC_PRICE_STEP&quot;).param_value)</p> <br /><p>local priceLAST = tonumber( getParamEx(class_code, sec_code, &quot;LAST&quot;).param_value )<br />-- Вычисляем цену, на которую выставим лимитную заявку на покупку</p><br /><p> local xxx -- Объявляем переменную xxx</p><p>&nbsp; &nbsp; if priceLAST/price_step &gt; 40610 then xxx = 131<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; elseif priceLAST/price_step &gt;&nbsp; &nbsp; 40300&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 130<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 39990&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 129<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 39680&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 128<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 39370&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 127<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 39060&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 126<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 38750&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 125<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 38440&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 124<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 38130&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 123<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 37820&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 122<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 37510&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 121<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 37200&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 120<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 36890&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 119<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 36580&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 118<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 36270&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 117<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 35960&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 116<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 35650&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 115<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 35340&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 114<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 35030&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 113<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 34720&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 112<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 34410&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 111<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 34100&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 110<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 33790&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 109<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 33480&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 108<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 33170&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 107<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 32860&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 106<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 32550&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 105<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 32240&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 104<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 31930&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 103<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 31620&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 102<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 31310&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 101<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 31000&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 100<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 30690&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 99<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 30380&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 98<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 30070&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 97<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 29760&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 96<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 29450&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 95<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 29140&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 94<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 28830&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 93<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 28520&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 92<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 28210&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 91<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 27900&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 90<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 27590&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 89<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 27280&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 88<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 26970&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 87<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 26660&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 86<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 26350&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 85<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 26040&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 84<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 25730&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 83<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 25420&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 82<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 25110&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 81<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 24800&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 80<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 24490&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 79<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 24180&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 78<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 23870&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 77<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 23560&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 76<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 23250&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 75<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 22940&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 74<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 22630&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 73<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 22320&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 72<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 22010&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 71<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 21700&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 70<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 21390&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 69<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 21080&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 68<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 20770&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 67<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 20460&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 66<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 20150&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 65<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 19840&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 64<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 19530&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 63<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 19220&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 62<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 18910&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 61<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 18600&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 60<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 18290&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 59<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 17980&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 58<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 17670&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 57<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 17360&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 56<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 17050&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 55<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 16740&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 54<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 16430&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 53<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 16120&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 52<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 15810&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 51<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 15500&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 50<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 15190&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 49<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 14880&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 48<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 14570&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 47<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 14260&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 46<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 13950&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 45<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 13640&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 44<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 13330&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 43<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 13020&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 42<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 12710&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 41<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 12400&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 40<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 12090&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 39<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 11780&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 38<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 11470&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 37<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 11160&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 36<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 10850&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 35<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 10540&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 34<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 10230&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 33<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 9920&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 32<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 9610&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 31<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 9300&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 30<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 8990&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 29<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 8680&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 28<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 8370&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 27<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 8060&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 26<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 7750&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 25<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 7440&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 24<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 7130&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 23<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 6820&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 22<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 6510&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 21<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 6200&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 20<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 5890&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 19<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 5580&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 18<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 5270&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 17<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 4960&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 16<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 4650&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 15<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 4340&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 14<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 4030&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 13<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 3720&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 12<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 3410&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 11<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 3100&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 10<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 2790&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 9<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 2480&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 8<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 2170&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 7<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 1860&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 6<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 1550&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 5<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 1240&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 4<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 930&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 3<br />elseif priceLAST/price_step &gt;&nbsp; &nbsp; 620&nbsp; &nbsp; then xxx =&nbsp; &nbsp; 2</p><p>&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; </p><br /><br /><p> local buy_price = priceLAST - price_step * (xxx*4 + 5)&nbsp; -- цена выставится при сработке стопа, лонг тоесть - и цена чуть ниже цены последних&nbsp; сделок</p><p>local take_profit_offset = priceLAST + price_step * xxx<br />local take_profit_offset1 = math.floor(take_profit_offset)<br />local take_profit_offset2 = tostring(take_profit_offset1)</p><p>local stop_loss_offset = priceLAST - price_step * (xxx*4-2)-- цена сработки стопа<br />local stop_loss_offset1 = math.floor(stop_loss_offset)&nbsp; &nbsp;--&nbsp; math.floor много бед из за нее&nbsp; tostring надо <br />local stop_loss_offset2 = tostring(stop_loss_offset1)</p> <br /> <br /> <br /> <br /> <br /> <br /><br /><p>local order_params = {<br />ACCOUNT = &quot;ххххххххххх&quot;,<br />CLASSCODE = &quot;TQBR&quot;,<br />CLIENT_CODE = &quot;ххххххх&quot;,<br />ACTION = &quot;NEW_STOP_ORDER&quot;,<br />TRANS_ID = &quot;1&quot;,<br />SECCODE = sec_code,</p><br /><p>OPERATION = &quot;S&quot;, -- Тип операции (B - покупка&nbsp; «S» - продажа.)<br />PRICE = tostring(buy_price), -- цена для стопа<br />QUANTITY = lots1,</p> <br /><p> STOP_ORDER_KIND = &quot;TAKE_PROFIT_AND_STOP_LIMIT_ORDER&quot;, <br /> STOPPRICE = tostring(take_profit_offset), --профит - обязательно<br /> STOPPRICE2 = tostring(stop_loss_offset), --стоп&nbsp; tostring - обязательно<br /> OFFSET_UNITS = &quot;PERCENTS&quot;,<br /> OFFSET = &quot;0&quot;,<br /> SPREAD_UNITS = &quot;PERCENTS&quot;,<br /> SPREAD&nbsp; = &quot;0&quot;,<br /> --MARKET_TAKE_PROFIT = &quot;YES&quot;,</p><br /><br /><p>EXPIRY_DATE = &quot;TODAY&quot;<br />}</p><p>--&nbsp; &nbsp; &nbsp; OFFSET&nbsp; &nbsp; -&nbsp; &nbsp; Величина отступа от максимума (минимума) цены последнеи? сделки. Используется при «STOP_ORDER_KIND» = «TAKE_PROFIT_STOP_ORDER» или «ACTIVATED_BY_ORDER_TAKE_PROFIT_STOP_ORDER»<br />-- OFFSET_UNITS&nbsp; &nbsp; -&nbsp; &nbsp; Единицы измерения отступа. Возможные значения: «PERCENTS» – в процентах (шаг изменения – одна сотая процента),«PRICE_UNITS» – в параметрах цены (шаг изменения равен шагу цены по данному инструменту)Используется при «STOP_ORDER_KIND» = «TAKE_PROFIT_STOP_ORDER» или «ACTIVATED_BY_ORDER_TAKE_PROFIT_STOP_ORDER»<br />&nbsp; &nbsp; &nbsp;-- SPREAD&nbsp; &nbsp; -&nbsp; &nbsp; Величина защитного спрэда. Используется при&nbsp; &nbsp; <br />-- SPREAD_UNITS&nbsp; &nbsp; -&nbsp; &nbsp; Единицы измерения защитного спрэда. Возможные значения: «PERCENTS» – в процентах (шаг изменения – одна сотая процента),«PRICE_UNITS» – в параметрах цены (шаг изменения равен шагу цены<br />-- BASE_ORDER_KEY&nbsp; &nbsp; -&nbsp; &nbsp; Регистрационныи? номер заявки-условия. Используется при</p><br /><br /><br /><br /><br /><p>-- отправляем заявку на сервер QUIK<br />local result = sendTransaction(order_params)</p><p>if result ~= &quot;OK&quot; then<br />--если при отправке заявки произошла ошибка, выводим сообщение об ошибке<br />message(&quot;Ошибка при отправке заявки: &quot; .. result)<br />else<br />--если заявка была успешно отправлена, выводим сообщение об успешном выполнении<br />message(&quot;Заявка успешно отправлена&quot;)<br />end -- закрываем блок &#039;if&#039;</p>]]></content>
			<author>
				<name><![CDATA[Alexey89]]></name>
				<uri>https://quik2dde.ru/profile.php?id=3408</uri>
			</author>
			<updated>2023-07-05T06:31:58Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=4261#p4261</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[добавить к цене акции число для стопа и профита.]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=4260#p4260" />
			<content type="html"><![CDATA[<p>Здравствуйте. </p><p>Пытался сделать универсальный скрипт. Он работает с любой акцией из последней заявки таблицы заявок. Автоматом считает стоп и тейк. Не могу задать цену на 0,5% выше или ниже текущей. Пытался задать стоп и тейк в количестве шагов цены, но у каждой бумаги разные шаги по отношению к ее цене. 30 шагов цены где-то это 0,2% а где-то 1,5%.&nbsp; Не подходит. А если задавать цену процентом, то часто цена не попадает в шаг цены и ошибки не дают работать скрипту. Что посоветуете? наверняка я туплю и там одна маленькая строчка кода)) </p><br /><p>Колхоз что есть сейчас (грубый выбор числа шагов цены исходя из последней цены акции)</p><p> local buy_price = priceLAST + price_step * xxx </p><br /><br /><p> if priceLAST &gt; 10000 then<br />&nbsp; &nbsp; &nbsp; &nbsp; xxx = 20<br />&nbsp; &nbsp; elseif priceLAST &gt; 1000 then<br />&nbsp; &nbsp; &nbsp; &nbsp; xxx = 25<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; elseif priceLAST &gt; 400 then<br />&nbsp; &nbsp; &nbsp; &nbsp; xxx = 30&nbsp; -- РОСНЕФТЬ 477.2&nbsp; &nbsp;0,3&nbsp; &nbsp; ЭН ГРУПП 481,8 30 ШАГОВ 1,33 ПРОЦЕНТОВ<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; elseif priceLAST &gt; 220 then<br />&nbsp; &nbsp; &nbsp; &nbsp; xxx = 80&nbsp; -- СБЕРБАНК 238,65&nbsp; 80 ШАГОВ 0,3 ПРОЦЕНТА<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; elseif priceLAST &gt; 190 then<br />&nbsp; &nbsp; &nbsp; &nbsp; xxx = 6&nbsp; &nbsp; -- М ВИДЕО 193,3&nbsp; 6 ШАГОВ&nbsp; &nbsp;0,3 ПРИМЕРНО<br />&nbsp; &nbsp; &nbsp; &nbsp; elseif priceLAST &gt; 180 then<br />&nbsp; &nbsp; &nbsp; &nbsp; xxx = 11&nbsp; -- МЕЧЕЛ 189,45&nbsp; 11 ШАГОВ 0,3<br />&nbsp; &nbsp; &nbsp; &nbsp; elseif priceLAST &gt; 175 then<br />&nbsp; &nbsp; &nbsp; &nbsp; xxx = 48 --&nbsp; МЕЧЕЛ 179.26&nbsp; &nbsp;48 ШАГОВ&nbsp; 0,3 <br />&nbsp; &nbsp; &nbsp; &nbsp; <br /> end</p>]]></content>
			<author>
				<name><![CDATA[Alexey89]]></name>
				<uri>https://quik2dde.ru/profile.php?id=3408</uri>
			</author>
			<updated>2023-07-04T09:29:08Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=4260#p4260</id>
		</entry>
</feed>
