<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[QUIK -> DDE &mdash; Индикатор корреляции]]></title>
		<link>https://quik2dde.ru/viewtopic.php?id=87</link>
		<atom:link href="https://quik2dde.ru/extern.php?action=feed&amp;tid=87&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Индикатор корреляции».]]></description>
		<lastBuildDate>Sat, 23 May 2015 16:39:24 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Индикатор корреляции]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=1378#p1378</link>
			<description><![CDATA[<p>-</p>]]></description>
			<author><![CDATA[null@example.com (sam063rus)]]></author>
			<pubDate>Sat, 23 May 2015 16:39:24 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=1378#p1378</guid>
		</item>
		<item>
			<title><![CDATA[Re: Индикатор корреляции]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=531#p531</link>
			<description><![CDATA[<p>Причина вот в чем.</p><p>Вот в этой строке</p><p>&nbsp; &nbsp; t,n,s = getCandlesByIndex(Settings.tag,0,n-Settings.period,Settings.period)</p><p>вы получаете таблицу <strong>t</strong> размером 10 элементов (т.к. Settings.period = 10, если смотреть на параметры по умолчанию). Причем индексы полученных элементов - от 0 до 9 включительно (т.е. существуют элементы t[0], t[1] .. t[9]) .</p><p>Далее, в цикле for вы формируете значение <strong>i</strong>, которое передаете в <strong>dMas</strong>() для индексации таблицы <strong>t</strong>:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; for i = index-Settings.period+1, index do<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xy = xy + dValue(i, Settings.value_type) * dMas(i, Settings.value_type)<br />&nbsp; &nbsp; &nbsp; &nbsp; end</p><p>Видно, что, например, для 100-й свечи графика (т.е. значении 100 в переменной <strong>index</strong>) значение <strong>i</strong> будет меняться от 91 до 100. Но в таблице <strong>t</strong> нет ведь таких индексов. Там только от 0 до 9.</p>]]></description>
			<author><![CDATA[null@example.com (swerg)]]></author>
			<pubDate>Mon, 24 Feb 2014 17:53:19 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=531#p531</guid>
		</item>
		<item>
			<title><![CDATA[Индикатор корреляции]]></title>
			<link>https://quik2dde.ru/viewtopic.php?pid=530#p530</link>
			<description><![CDATA[<p>Помогите подправить код, не пойму где я накосячил)</p><div class="codebox"><pre><code>Settings=
{
    Name = &quot;Correl&quot;,
    tag = &quot;rts&quot;,
    period = 10,
    value_type = &quot;C&quot;,
    line = 
    {
        {
            Name = &quot;MA&quot;,
            Color = RGB(255, 0, 0),
            Type = TYPE_LINE,
            Width = 1
        }
    }
}
 
function dValue(i,param)
    local v = param or &quot;C&quot;
    
    if         v == &quot;O&quot; then 
                return O(i)
    elseif     v == &quot;H&quot; then
                return H(i)
    elseif     v == &quot;L&quot; then
                return L(i)
    elseif     v == &quot;C&quot; then
                return C(i)
    elseif     v == &quot;V&quot; then
                return V(i)
    elseif     v == &quot;M&quot; then
                return (H(i) + L(i))/2
    elseif     v == &quot;T&quot; then
                return (H(i) + L(i)+C(i))/3
    elseif     v == &quot;W&quot; then
                return (H(i) + L(i)+2*C(i))/4
    else 
        return C(i)
    end
end
 
function Init()
    return 1
end
 
function OnCalculate(index)
    
    n = getNumCandles (Settings.tag)
    
    t,n,s = getCandlesByIndex(Settings.tag,0,n-Settings.period,Settings.period)
    
    function dMas(i,param)
    
        local v = param or &quot;C&quot;
    
        if         v == &quot;O&quot; then 
                    return t[i].open
        elseif     v == &quot;H&quot; then
                    return t[i].high
        elseif     v == &quot;L&quot; then
                    return t[i].low
        elseif     v == &quot;C&quot; then
                    return t[i].close --говорит, что = nil 
        elseif     v == &quot;M&quot; then
                    return (t[i].high + t[i].low)/2
        elseif     v == &quot;T&quot; then
                    return (t[i].high + t[i].low+t[i].close)/3
        elseif     v == &quot;W&quot; then
                    return (t[i].high + t[i].low+t[i].close*2)/4
        else 
            return t[i].close
        end
    end
    if index &lt; Settings.period then
        return nil
    else
        local xy = 0
        local x = 0
        local y = 0
        local x2 = 0
        local y2 = 0
        
        for i = index-Settings.period+1, index do
            
            xy = xy + dValue(i, Settings.value_type) * dMas(i, Settings.value_type)
            
        end
        
        for i = index-Settings.period+1, index do
            
            x = x + dValue(i, Settings.value_type)            
        end
        
        for i = index-Settings.period+1, index do
            
            y = y + dMas(i, Settings.value_type) 
            
        end
        
        for i = index-Settings.period+1, index do
            
            x2 = x2 + dValue(i, Settings.value_type)*dValue(i, Settings.value_type)
            
        end
        
        for i = index-Settings.period+1, index do
            
            y2 = y2 + dMas(i, Settings.value_type)*dMas(i, Settings.value_type)
            
        end
        
        r =(Settings.period*xy-x*y)/math.sqrt ((Settings.period*x2-x*x)*(Settings.period*y2-y*y))
        
        return r
    end
end</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (shishkir_aleksandr)]]></author>
			<pubDate>Sun, 23 Feb 2014 17:52:07 +0000</pubDate>
			<guid>https://quik2dde.ru/viewtopic.php?pid=530#p530</guid>
		</item>
	</channel>
</rss>
