<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forex Software — can a strategy deal with divergence / convergence]]></title>
		<link>https://forexsb.com/forum/topic/2157/can-a-strategy-deal-with-divergence-convergence/</link>
		<atom:link href="https://forexsb.com/forum/feed/rss/topic/2157/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in can a strategy deal with divergence / convergence.]]></description>
		<lastBuildDate>Sat, 05 Mar 2011 23:14:43 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: can a strategy deal with divergence / convergence]]></title>
			<link>https://forexsb.com/forum/post/8537/#p8537</link>
			<description><![CDATA[<p>Thank you, I will look for appropriate source code Mr Popov and explore erios suggested indicator, then report back through this thread.</p>]]></description>
			<author><![CDATA[null@example.com (dave88)]]></author>
			<pubDate>Sat, 05 Mar 2011 23:14:43 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/8537/#p8537</guid>
		</item>
		<item>
			<title><![CDATA[Re: can a strategy deal with divergence / convergence]]></title>
			<link>https://forexsb.com/forum/post/8494/#p8494</link>
			<description><![CDATA[<p>Hello Mr. Popov,</p><p>I think I can help here: I&#039;ve found a &quot;divergence indicator&quot; for MetaTrader from Pavel Kulko. See here:</p><div class="codebox"><pre><code>//+------------------------------------------------------------------+
//|                                                   Divergence.mq4 |
//|                                    Copyright © 2005, Pavel Kulko |
//|                                                  polk@alba.dp.ua |
//+------------------------------------------------------------------+
#property copyright &quot;Copyright © 2005, Pavel Kulko&quot;
#property link      &quot;polk@alba.dp.ua&quot;

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_minimum -1
#property indicator_maximum 1
#property indicator_color1 Aqua
#property indicator_color2 Red


   
extern int ind = 1;        //MACD=1,  RSI=2,  DMI=3,  Mom=4
extern int pds = 10;       //indicator periods
extern int f = 1;          //price field: Close=1, High/Low=2
extern double Ch = 0;      //peak/trough depth minimum (0-1)
extern int shift = 0;      //shift signals back to match divergences
extern int MaxBars=1000;
 
double DivUpBuffer[],DivDnBuffer[];  
double R1[],R2[],y[],xd[],xu[];
double fCh;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
   IndicatorBuffers(7);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexBuffer(0,DivUpBuffer);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexBuffer(1,DivDnBuffer);
   SetIndexBuffer(2,R1);
   SetIndexBuffer(3,R2);
   SetIndexBuffer(4,y);
   SetIndexBuffer(5,xd);
   SetIndexBuffer(6,xu);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int CNmb1,CNmb2,CNmb3,CNmb4;
   double Pkx1,Pkx2,Trx1,Trx2,Pky1,Pky2,Try1,Try2;
   bool Trx,Pkx,Try,Pky;
   
   fCh = Ch/100.0;
   
   int    counted_bars=IndicatorCounted();
   int limit = Bars-counted_bars-1;
   if(limit&gt;MaxBars) limit = MaxBars;
   for(int i=limit; i&gt;=0; i--) {
     DivUpBuffer[i] = Low[i];
     DivDnBuffer[i] = Low[i];
     switch(ind) {
       case 1: y[i] = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i); break;
       case 2: y[i] = iRSI(NULL,0,pds,PRICE_CLOSE,i); break;
       case 3: y[i] = iADX(NULL,0,pds,PRICE_CLOSE,MODE_MAIN,i); break;
       default : y[i] = iMomentum(NULL,0,pds,PRICE_CLOSE,i); break;
     }  
     if(f==1) xu[i] = Close[i];
     else xu[i] = High[i];
     if(f==1) xd[i] = Close[i];
     else xd[i] = Low[i];
   }
   for(i=limit; i&gt;=0; i--) {
     CNmb1 = 0; CNmb2 = 0; CNmb3 = 0; CNmb4 = 0;
     for(int j=i; j&lt;MaxBars; j++) {
       Pkx = (xu[j] &lt; xu[j-1]) &amp;&amp; (xu[j-1] &gt; xu[j-2]) &amp;&amp; (xu[j-1] &gt;= (xu[j]+xu[j-2])/2.0*(1.0+fCh));
       if(Pkx) CNmb1++;
       if(Pkx &amp;&amp; CNmb1==1) Pkx1 = xu[j-1];
       if(Pkx &amp;&amp; CNmb1==2) Pkx2 = xu[j-1];
     
       Trx = (xd[j] &gt; xd[j-1]) &amp;&amp; (xd[j-1] &lt; xd[j-2]) &amp;&amp; (xd[j-1] &lt;= (xd[j]+xd[j-2])/2.0*(1.0-fCh));
       if(Trx) CNmb2++;
       if(Trx &amp;&amp; CNmb2==1) Trx1 = xd[j-1];
       if(Trx &amp;&amp; CNmb2==2) Trx2 = xd[j-1];
     
       Pky = (y[j] &lt; y[j-1]) &amp;&amp; (y[j-1] &gt; y[j-2]) &amp;&amp; (y[j-1] &gt;= (y[j]+y[j-2])/2.0*(1.0+fCh));
       if(Pky) CNmb3++;
       if(Pky &amp;&amp; CNmb3==1) Pky1 = y[j-1];
       if(Pky &amp;&amp; CNmb3==2) Pky2 = y[j-1];
     
       Try = (y[j] &gt; y[j-1]) &amp;&amp; (y[j-1] &lt; y[j-2]) &amp;&amp; (y[j-1] &lt;= (y[j]+y[j-2])/2.0*(1.0-fCh));
       if(Try) CNmb4++;
       if(Try &amp;&amp; CNmb4==1) Try1 = y[j-1];
       if(Try &amp;&amp; CNmb4==2) Try2 = y[j-1];

       if(CNmb1&gt;=2 &amp;&amp; CNmb2&gt;=2 &amp;&amp; CNmb3&gt;=2 &amp;&amp; CNmb4&gt;=2) break;
     }  
     Pkx = (xu[i] &lt; xu[i-1]) &amp;&amp; (xu[i-1] &gt; xu[i-2]) &amp;&amp; (xu[i-1] &gt;= (xu[i]+xu[i-2])/2.0*(1.0+fCh));
     Trx = (xd[i] &gt; xd[i-1]) &amp;&amp; (xd[i-1] &lt; xd[i-2]) &amp;&amp; (xd[i-1] &lt;= (xd[i]+xd[i-2])/2.0*(1.0-fCh));
     Pky = (y[i] &lt; y[i-1]) &amp;&amp; (y[i-1] &gt; y[i-2]) &amp;&amp; (y[i-1] &gt;= (y[i]+y[i-2])/2.0*(1.0+fCh));
     Try = (y[i] &gt; y[i-1]) &amp;&amp; (y[i-1] &lt; y[i-2]) &amp;&amp; (y[i-1] &lt;= (y[i]+y[i-2])/2.0*(1.0-fCh));

     R1[i] = 0;
     if(Trx &amp;&amp; Try &amp;&amp; Trx1&lt;Trx2 &amp;&amp; Try1&gt;Try2) R1[i] = 1;
     R2[i] = 0;
     if(Pkx &amp;&amp; Pky &amp;&amp; Pkx1&gt;Pkx2 &amp;&amp; Pky1&lt;Pky2) R2[i] = 1;

     if(R1[i+shift] - R2[i+shift] &gt; 0) {
       DivUpBuffer[i+shift] = High[i];
       DivDnBuffer[i+shift] = Low[i];
     }
     if(R1[i+shift] - R2[i+shift] &lt; 0) {
       DivDnBuffer[i] = High[i];
       DivUpBuffer[i] = Low[i];
     }
   }
   return(0);
}
//+------------------------------------------------------------------+</code></pre></div><p>For further helpful sources for MetaTrader I can recommend <a href="http://search4metatrader.com/">http://search4metatrader.com/</a></p><p>Best wishes,<br />erio</p>]]></description>
			<author><![CDATA[null@example.com (erio)]]></author>
			<pubDate>Fri, 04 Mar 2011 08:07:09 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/8494/#p8494</guid>
		</item>
		<item>
			<title><![CDATA[Re: can a strategy deal with divergence / convergence]]></title>
			<link>https://forexsb.com/forum/post/8493/#p8493</link>
			<description><![CDATA[<p>To do this you have to make a special custom indicator with such logic rules. <br />This may be a useful indicator. If you find something about this topic or even a MT source code, I&#039;ll try to make such indicator.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Fri, 04 Mar 2011 07:37:24 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/8493/#p8493</guid>
		</item>
		<item>
			<title><![CDATA[can a strategy deal with divergence / convergence]]></title>
			<link>https://forexsb.com/forum/post/8492/#p8492</link>
			<description><![CDATA[<p>wondering if it is possible to deal with divergence/convergence when automating a strategy</p><p>for example when using the MACD, you may get successive entry signals, but not want to take an entry where the price has converged with the indicator, relative to the previous entry</p><p>I would actually like any advice on:</p><p>1.&nbsp; whether this can be addressed with FSB, and<br />2. if not, could you point me in a direction where I might be able to research and find an answer</p><p>thanks in advance!!</p>]]></description>
			<author><![CDATA[null@example.com (dave88)]]></author>
			<pubDate>Fri, 04 Mar 2011 07:32:19 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/8492/#p8492</guid>
		</item>
	</channel>
</rss>
