<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>BullCharts : RSI Divergence</title>
  <link>http://www.bullcharts.com.au/forum/</link>
  <description>This is an XML content feed of; BullCharts : BullScript : RSI Divergence</description>
  <copyright>Copyright (c) 2006-2009 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 15 Apr 2026 13:30:19 +0000</pubDate>
  <lastBuildDate>Wed, 17 Aug 2005 00:09:57 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.bullcharts.com.au/forum/RSS_post_feed.asp?TID=282</WebWizForums:feedURL>
  <image>
   <title>BullCharts</title>
   <url>http://www.bullcharts.com.au/forum/http://www.bullcharts.com.au/images/bull_logo.gif</url>
   <link>http://www.bullcharts.com.au/forum/</link>
  </image>
  <item>
   <title>RSI Divergence : Wow !! you have exceled Tim, I...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=1008#1008</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=53" rel="nofollow">etrader</a><br /><strong>Subject:</strong> 282<br /><strong>Posted:</strong> 17&nbsp;Aug&nbsp;2005 at 12:09am<br /><br /><P>Wow&nbsp; !! you have exceled Tim, I really appreciate the time and effort you have put in to explain things, and this will definately help me and others I am sure, to work through some practical Bullscript. I'll study this and&nbsp;no doubt will&nbsp;gain some useful knowledge for future reference.&nbsp;</P><P>cheers etrader.</P>]]>
   </description>
   <pubDate>Wed, 17 Aug 2005 00:09:57 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=1008#1008</guid>
  </item> 
  <item>
   <title>RSI Divergence :   Originally posted by etraderI...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=1004#1004</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=5" rel="nofollow">Tim Allen</a><br /><strong>Subject:</strong> 282<br /><strong>Posted:</strong> 16&nbsp;Aug&nbsp;2005 at 4:05pm<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by etrader</strong></em><br /><br />I did try and copy and paste but got this error initially.<br><p><img src="uploads/etrader/2005-08-15_203659_untitled.jpg" border="0"></p><p></td></tr></table></p>I'm not quite sure how MetaStock handles these things, but BullCharts expects that an indicator will contain a single formula, unless it encounters a semi-colon. "5 7" is a non-sensical mathematical expression, and so putting two if statements together as your MetaStock formula does is just as confusing.<br><br>The simple solution is: put a semi-colon after the first expression, like this:<br><table width="99%"><tr><td><pre class="BBcode">{RSI(9) DIVERGENCE BUY:}<br>If(RSI(9) &gt;= HHV(RSI(9),19) AND CLOSE &lt;HHV(CLOSE,19), 1, 0) <br>OR <br>If(CLOSE &lt;= LLV(CLOSE,19) AND RSI(9) &gt; LLV(RSI(9),19), 1, 0);<br><br>{RSI(9) DIVERGENCE SELL:}<br>If(CLOSE &gt;= HHV(CLOSE,19) AND RSI(9)&lt;HHV(RSI(9),19), 1, 0)<br>OR<br>If(RSI(9) &lt;= LLV(RSI(9),19) AND CLOSE &gt; LLV(CLOSE,19), 1, 0);<br></pre></td></tr></table><br><p><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by etrader</strong></em><br /><br />I tried this also below which returned no errors, but not sure what the 0 is at the end. I would have expected maybe more returns ??</p><p><font color="#008000" size="2"><p>{RSI(9) DIVERGENCE BUY:}</p></font><font color="#0000c0"></font></p><p><font color="#0000c0"><font size="2">IF</font></font><font size="2"> (rsi(<font color="#0000c0">close</font>,9) &gt;= <font color="#0000c0">HHV</font>(RSI(<font color="#0000c0">close</font>,9),19) <font color="#0000c0">AND</font> <font color="#0000c0">CLOSE</font> &lt; <font color="#0000c0">HHV</font>(<font color="#0000c0">CLOSE</font>,19),1,0) <font color="#0000c0">OR</font> </font></p><font color="#0000c0"></font><p><font color="#0000c0"><font size="2">IF</font></font><font size="2"> (<font color="#0000c0">CLOSE</font> &lt;= <font color="#0000c0">LLV</font>(<font color="#0000c0">CLOSE</font>,19) <font color="#0000c0">AND</font> RSI(9) &gt; <font color="#0000c0">LLV</font>(RSI(<font color="#0000c0">close</font>,9),19), 1,0);</font></p></td></tr></table><br><br>That's the same as the first half of what I got, so you're doing alright there. However, when I add that indicator to a chart of, say, BHP or TLS, I get a steady, unwavering line at 0, indicating that this particular signal never went off.<br><br>When I look at a big, complicated expression like this, I can't imagine how it works all in my head at the same time, so I'm going to break it up into smaller components and see how those work.<br><ul><li>I'm going to delete the SELL half of the indicator to simplify things, because it's basically just the inverse of the BUY half - whatever makes the BUY half work should make the SELL half work as well.</li><li>I'm going to comment-out the BUY half, because I know it always returns 0, so it'll just get in the way. I won't delete it because I want to copy-and-paste things from it.</li><li>When I look at the BUY indicator, the first thing I notice is that it's got two conditions, linked by an OR: "<span style="font-style: italic;">cond1</span> OR <span style="font-style: italic;">cond2</span>". So it would be a good idea to investigate each of these conditions separately before putting them together.</li><li>The first condition is silly, since it looks like this: "if(<span style="font-style: italic;">cond3</span>, 1, 0)". Basically, if <span style="font-style: italic;">cond3</span> is true, the if() function returns true. If <span style="font-style: italic;">cond3</span> is false, the if() function returns false. Therefore "if(<span style="font-style: italic;">cond3</span>, 1, 0)" is exactly equivalent to "(<span style="font-style: italic;">cond3</span>)". So let's look at <span style="font-style: italic;">cond3</span>.</li><li>cond3 contains two expressions, linked with an AND: "RSI(9) &gt;= HHV(RSI(9),19) AND CLOSE &lt;HHV(CLOSE,19)". Let's look at both halves of the indicator individually, and see what happens.</li></ul>Our indicator so far:<br><table width="99%"><tr><td><pre class="BBcode"><span style="color: rgb(0, 102, 0);">{RSI(9) DIVERGENCE BUY:}</span><br style="color: rgb(0, 102, 0);"><span style="color: rgb(0, 102, 0);">{</span><br style="color: rgb(0, 102, 0);"><span style="color: rgb(0, 102, 0);">If(RSI(9) &gt;= HHV(RSI(9),19) AND CLOSE &lt;HHV(CLOSE,19),1,0) </span><br style="color: rgb(0, 102, 0);"><span style="color: rgb(0, 102, 0);">OR </span><br style="color: rgb(0, 102, 0);"><span style="color: rgb(0, 102, 0);">If(CLOSE &lt;= LLV(CLOSE,19) AND RSI(9) &gt; LLV(RSI(9),19),1,0);</span><br style="color: rgb(0, 102, 0);"><span style="color: rgb(0, 102, 0);">}</span><br><br>RSI(9) &gt;= <span style="color: rgb(0, 0, 153);">HHV</span>(RSI(9),19);<br><span style="color: rgb(0, 0, 153);">CLOSE</span> &lt; <span style="color: rgb(0, 0, 153);">HHV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>,19);<br></pre></td></tr></table><br>Hmm... this indicator fires signals all over the place, so something's going on there. However, since all I can see is blue, I'm not sure which bits are which expression. Let's add some colours to the indicator so we can tell the lines apart:<br><br><table width="99%"><tr><td><pre class="BBcode"><span style="color: rgb(153, 0, 153);">&#091;color</span>=red<span style="color: rgb(153, 0, 153);">&#093;</span><br>RSI(9) &gt;= <span style="color: rgb(0, 0, 153);">HHV</span>(RSI(9),19);<br><span style="color: rgb(153, 0, 153);">&#091;color</span>=blue<span style="color: rgb(153, 0, 153);">&#093;</span><br><span style="color: rgb(0, 0, 153);">CLOSE</span> &lt; <span style="color: rgb(0, 0, 153);">HHV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>,19);<br></pre></td></tr></table><br>Hmm.. all blue, no red. I think there must be something wrong with the first expression, although it looks simple enough... Looking in the Script Helper (tick 'Show script helper' at the bottom of the indicator window), I see that the RSI function is supposed to take two parameters - an expression and a period. Let's change the first expression to include CLOSE:<br><br><table width="99%"><tr><td><pre class="BBcode"><span style="color: rgb(153, 0, 153);">&#091;color</span>=red<span style="color: rgb(153, 0, 153);">&#093;</span><br>RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &gt;= <span style="color: rgb(0, 0, 153);">HHV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9),19);<br><span style="color: rgb(153, 0, 153);">&#091;color</span>=blue<span style="color: rgb(153, 0, 153);">&#093;</span><br><span style="color: rgb(0, 0, 153);">CLOSE</span> &lt; <span style="color: rgb(0, 0, 153);">HHV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>,19);<br></pre></td></tr></table><br>Ah, now we've got a dancing blue line and a dancing red line. If I combine both of those back into <span style="font-style: italic;">cond3</span>:<br><br><table width="99%"><tr><td><pre class="BBcode">RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &gt;= <span style="color: rgb(0, 0, 153);">HHV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9),19) <span style="color: rgb(0, 0, 153);">AND</span> <span style="color: rgb(153, 0, 153);"></span><span style="color: rgb(0, 0, 153);">CLOSE</span> &lt; <span style="color: rgb(0, 0, 153);">HHV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>,19);<br></pre></td></tr></table><br>...then I get a line that spikes only occasionally, which is more like what I expected an indicator to do. So let's put the BUY and SELL signals back together, with everything we've learned:<br><br><table width="99%"><tr><td><pre class="BBcode"><span style="color: rgb(0, 153, 0);">{RSI(9) DIVERGENCE BUY:}</span><br>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &gt;= <span style="color: rgb(0, 0, 153);">HHV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9), 19) <span style="color: rgb(0, 0, 153);">AND</span> <span style="color: rgb(0, 0, 153);">CLOSE </span>&lt; <span style="color: rgb(0, 0, 153);">HHV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 19)) <br><span style="color: rgb(0, 0, 153);">OR </span><br>(<span style="color: rgb(0, 0, 153);">CLOSE </span>&lt;= <span style="color: rgb(0, 0, 153);">LLV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 19) <span style="color: rgb(0, 0, 153);">AND </span>RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &gt; <span style="color: rgb(0, 0, 153);">LLV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9), 19));<br><br><span style="color: rgb(0, 153, 0);">{RSI(9) DIVERGENCE SELL:}</span><br>(<span style="color: rgb(0, 0, 153);">CLOSE </span>&gt;= <span style="color: rgb(0, 0, 153);">HHV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 19) <span style="color: rgb(0, 0, 153);">AND </span>RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &lt; <span style="color: rgb(0, 0, 153);">HHV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9), 19))<br><span style="color: rgb(0, 0, 153);">OR</span><br>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &lt;= <span style="color: rgb(0, 0, 153);">LLV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9), 19) <span style="color: rgb(0, 0, 153);">AND CLOSE </span>&gt; <span style="color: rgb(0, 0, 153);">LLV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 19));<br></pre></td></tr></table><br>I don't know if that's exactly the output you were expecting, but it certainly seems a lot more informative than it did to start with.<br><br><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by etrader</strong></em><br /><br />I understand what divergence is, and that we are looking for a higher RSI value after 19 bars and a lower close after 19 bars &#091;and the opposite for the LLV&#093;, but the problem I have is my programming iliteracy I guess, and how to make this totally effective with markers etc.<font color="#008000" size="2"></font></td></tr></table><br><br>Markers are really simple, once you've got an indicator that does more or less what you want (as we have here). For details, see the Attribute Reference in the BullScript Help, but to start you off here's the same formula as above, but with attributes added to turn the lines into markers:<br><br><table width="99%"><tr><td><pre class="BBcode"><span style="color: rgb(153, 0, 153);">&#091;target</span>=Price<span style="color: rgb(153, 0, 153);">&#093;</span><br><br><span style="color: rgb(0, 153, 0);">{RSI(9) DIVERGENCE BUY:}</span><br><span style="color: rgb(153, 0, 153);">&#091;name</span>=Type1<span style="color: rgb(153, 0, 153);">; linestyle</span>=marker<span style="color: rgb(153, 0, 153);">; marker</span>=type1<span style="color: rgb(153, 0, 153);">; tooltip</span>="Decide for yourself what you should do in this situation"<span style="color: rgb(153, 0, 153);">&#093;</span><br>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &gt;= <span style="color: rgb(0, 0, 153);">HHV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9), 19) <span style="color: rgb(0, 0, 153);">AND CLOSE </span>&lt; <span style="color: rgb(0, 0, 153);">HHV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 19)) <br><span style="color: rgb(0, 0, 153);">OR </span><br>(<span style="color: rgb(0, 0, 153);">CLOSE </span>&lt;= <span style="color: rgb(0, 0, 153);">LLV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 19) <span style="color: rgb(0, 0, 153);">AND </span>RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &gt; <span style="color: rgb(0, 0, 153);">LLV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9), 19));<br><br><span style="color: rgb(0, 153, 0);">{RSI(9) DIVERGENCE SELL:}</span><br><span style="color: rgb(153, 0, 153);">&#091;name</span>=Type2<span style="color: rgb(153, 0, 153);">; linestyle</span>=marker<span style="color: rgb(153, 0, 153);">; marker</span>=type2<span style="color: rgb(153, 0, 153);">; tooltip</span>="Decide for yourself what you should do in this situation"&#093;<br>(<span style="color: rgb(0, 0, 153);">CLOSE </span>&gt;= <span style="color: rgb(0, 0, 153);">HHV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 19) <span style="color: rgb(0, 0, 153);">AND </span>RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &lt; <span style="color: rgb(0, 0, 153);">HHV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9), 19))<br><span style="color: rgb(0, 0, 153);">OR</span><br>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9) &lt;= <span style="color: rgb(0, 0, 153);">LLV</span>(RSI(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 9), 19) <span style="color: rgb(0, 0, 153);">AND CLOSE </span>&gt; <span style="color: rgb(0, 0, 153);">LLV</span>(<span style="color: rgb(0, 0, 153);">CLOSE</span>, 19));<br></pre></td></tr></table><br><br><img border="0" src="http://www.bullcharts.com.au/forum/smileys/smiley2.gif" border="0"><br>]]>
   </description>
   <pubDate>Tue, 16 Aug 2005 16:05:56 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=1004#1004</guid>
  </item> 
  <item>
   <title>RSI Divergence : I did try and copy and paste but...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=1003#1003</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=53" rel="nofollow">etrader</a><br /><strong>Subject:</strong> 282<br /><strong>Posted:</strong> 15&nbsp;Aug&nbsp;2005 at 8:52pm<br /><br /><P>I did try and copy and paste but got this error initially.</P><P><IMG src="uploads/etrader/2005-08-15_203659_untitled.jpg" border="0"></P><P>I am not a programmer so am trying to understand the IF's and buts. I tried this also below which returned no errors, but not sure what the 0 is at the end. I would have expected maybe more returns ??</P><P>I understand what divergence is, and that we are looking for a higher RSI value after 19 bars and a lower close after 19 bars &#091;and the opposite for the LLV&#093;, but the problem I have is my programming iliteracy I guess, and how to make this totally effective with markers etc.</P><FONT color=#008000 size=2><P>{RSI(9) DIVERGENCE BUY:}</P></FONT><FONT color=#0000c0><P><FONT size=2>IF</FONT></FONT><FONT size=2> (rsi(<FONT color=#0000c0>close</FONT>,9) &gt;= <FONT color=#0000c0>HHV</FONT>(RSI(<FONT color=#0000c0>close</FONT>,9),19) <FONT color=#0000c0>AND</FONT> <FONT color=#0000c0>CLOSE</FONT> &lt; <FONT color=#0000c0>HHV</FONT>(<FONT color=#0000c0>CLOSE</FONT>,19),1,0) <FONT color=#0000c0>OR</FONT> </FONT></P><FONT color=#0000c0><P><FONT size=2>IF</FONT></FONT><FONT size=2> (<FONT color=#0000c0>CLOSE</FONT> &lt;= <FONT color=#0000c0>LLV</FONT>(<FONT color=#0000c0>CLOSE</FONT>,19) <FONT color=#0000c0>AND</FONT> RSI(9) &gt; <FONT color=#0000c0>LLV</FONT>(RSI(<FONT color=#0000c0>close</FONT>,9),19), 1,0);</FONT></P>]]>
   </description>
   <pubDate>Mon, 15 Aug 2005 20:52:23 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=1003#1003</guid>
  </item> 
  <item>
   <title>RSI Divergence : Before I get too far in, what...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=1001#1001</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=5" rel="nofollow">Tim Allen</a><br /><strong>Subject:</strong> 282<br /><strong>Posted:</strong> 15&nbsp;Aug&nbsp;2005 at 10:35am<br /><br />Before I get too far in, what BullScript did you come up with, and what did it do that you didn't expect?]]>
   </description>
   <pubDate>Mon, 15 Aug 2005 10:35:41 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=1001#1001</guid>
  </item> 
  <item>
   <title>RSI Divergence : I would appreciate if you could...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=998#998</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=53" rel="nofollow">etrader</a><br /><strong>Subject:</strong> 282<br /><strong>Posted:</strong> 12&nbsp;Aug&nbsp;2005 at 12:43pm<br /><br /><H2><FONT face="Verdana, Arial, Helvetica, sans-serif" color=#000000 size=1>I would appreciate if you could help with this conversion from Metastock to bullscript&nbsp;Tim. I thought i could work it out, but got stuck.</FONT></H2><H2><FONT face="Verdana, Arial, Helvetica, sans-serif" color=#000000 size=1><A name="RSI Divergence"><strong>RSI Divergence</strong></A></FONT></H2><P><FONT face="Verdana, Arial, Helvetica, sans-serif" size=1>{RSI(9) DIVERGENCE BUY:}<BR>If(RSI(9) &gt;= HHV(RSI(9),19) AND CLOSE &lt;HHV(CLOSE,19), 1,0) OR<BR>If(CLOSE &lt;= LLV(CLOSE,19) AND RSI(9) &gt; LLV(RSI(9),19), 1,0)<BR><BR>{RSI(9) DIVERGENCE SELL:}<BR>If(CLOSE &gt;= HHV(CLOSE,19) AND RSI(9)&lt;HHV(RSI(9),19),1,0) OR<BR>If(RSI(9) &lt;= LLV(RSI(9),19) AND CLOSE &gt; LLV(CLOSE,19),1,0)<BR><BR>{You can substitute any formula for the "RSI(9)"} </FONT></P><P>cheers etrader</P><span style="font-size:10px"><br /><br />Edited by etrader</span>]]>
   </description>
   <pubDate>Fri, 12 Aug 2005 12:43:48 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=282&amp;PID=998#998</guid>
  </item> 
 </channel>
</rss>