<?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 : Problem averaging only positive values</title>
  <link>http://www.bullcharts.com.au/forum/</link>
  <description>This is an XML content feed of; BullCharts : BullScript : Problem averaging only positive values</description>
  <copyright>Copyright (c) 2006-2009 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Fri, 10 Apr 2026 19:16:12 +0000</pubDate>
  <lastBuildDate>Thu, 11 Jan 2018 22:54:54 +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=1012</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>Problem averaging only positive values : Thanks, they work well!   I had...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3542#3542</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=189" rel="nofollow">maximo</a><br /><strong>Subject:</strong> 1012<br /><strong>Posted:</strong> 11&nbsp;Jan&nbsp;2018 at 10:54pm<br /><br />Thanks, they work well!<br /><br /><br />I had a similar issue of 'only positive values' with calculating monthly returns in a scan.  Min value fixed it.<br /><br />((O-Ref(O,-21)) / min(O,Ref(O,-21)))*100;<br /><br /><br /><br /> <br /><br /><br /><br /><span style="font-size:10px"><br /><br />Edited by maximo - 13&nbsp;Jan&nbsp;2018 at 6:16pm</span>]]>
   </description>
   <pubDate>Thu, 11 Jan 2018 22:54:54 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3542#3542</guid>
  </item> 
  <item>
   <title>Problem averaging only positive values : Thanks for your earlier help,...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3530#3530</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=196" rel="nofollow">cudderbean</a><br /><strong>Subject:</strong> 1012<br /><strong>Posted:</strong> 25&nbsp;Jul&nbsp;2017 at 5:27pm<br /><br /><div>Thanks for your earlier help, admin.</div><div><br></div><div>As always, not the Holy Grail, but perhaps just a warning sign to help make a decision if you feel you are in an overbought or oversold position.</div><div><br></div><div>Play with the parameters to suit your trading style. Let me know coding errors or improvements. Thanks.</div><div><br></div><div><b><u>LINE CHART FORMAT</u></b></div><div><br></div><div>&#091;description=" Drifter. Measures how far closing price tends to drift away before reverting to mean"&#093;</div><div>&#091;target=default&#093;</div><div><br></div><div>cn<span style="white-space:pre">	</span>:= input("MA close time periods",10,1);</div><div>cma<span style="white-space:pre">	</span>:= ma(c,cn,simple);</div><div>drift := c-cma;</div><div>n <span style="white-space:pre">	</span>:= input("MA drift time periods",5,1);</div><div>method := inputma("Driftma method",SIMPLE);</div><div>driftma<span style="white-space:pre">	</span>:= hist(ma(drift,n,method),1);</div><div>driftup := if(c&gt;=cma,c-cma,undefined);</div><div>driftdwn := if(c&lt;cma,cma-c,undefined)*-1;</div><div>sdfactor := input("Multiple of stdev",1.0,0);</div><div><br></div><div>avedriftup := hist(ma(driftup,250,s),1); {average amount drifts up over last 250 periods}</div><div>sd_driftup := hist(stdev(driftup,250),1); {st dev amount drifts up over last 250 periods}</div><div>extremdriftup :=avedriftup+(sd_driftup*sdfactor);</div><div><br></div><div>avedriftdwn := hist(ma(driftdwn,250,s),1); {average amount drifts down over last 250 periods}</div><div>sd_driftdwn := hist(stdev(driftdwn,250),1); {st dev amount drifts down over last 250 periods}</div><div>extremdriftdwn :=avedriftdwn+(sd_driftdwn*sdfactor)*-1;</div><div><br></div><div>&#091;horzline=0&#093;</div><div><br></div><div>&#091;color=blue;name=drift&#093;</div><div>drift;</div><div><br></div><div>&#091;color=red;name=driftma&#093;</div><div>driftma;</div><div><br></div><div>&#091;color=purple;name=extremdriftup&#093;</div><div>extremdriftup;</div><div><br></div><div>&#091;color=purple;name=extremdriftdwn&#093;</div><div>extremdriftdwn;</div><div><br></div><div>...............................</div><div><br></div><div><b><u>RIBBON FORMAT</u></b></div><div><br></div><div><span style=": rgb244, 244, 251;">&#091;description=" Drifter. Measures how far closing price tends to drift away before reverting to mean"&#093;</span></div><div>&#091;target=ribbon&#093;</div><div><br></div><div>cn<span style="white-space:pre">	</span>:= input("MA close time periods",10,1);</div><div>cma<span style="white-space:pre">	</span>:= ma(c,cn,simple);</div><div>drift := c-cma;</div><div>n <span style="white-space:pre">	</span>:= input("MA drift time periods",5,1);</div><div>method := inputma("Driftma method",SIMPLE);</div><div>driftma<span style="white-space:pre">	</span>:= hist(ma(drift,n,method),1);</div><div>driftup := if(c&gt;=cma,c-cma,undefined);</div><div>driftdwn := if(c&lt;cma,cma-c,undefined)*-1;</div><div>sdfactor := input("Multiple of stdev",1.0,0);</div><div><br></div><div>avedriftup := hist(ma(driftup,250,s),1); {average amount drifts up over last 250 periods}</div><div>sd_driftup := hist(stdev(driftup,250),1); {st dev amount drifts up over last 250 periods}</div><div>extremdriftup :=avedriftup+(sd_driftup*sdfactor);</div><div><br></div><div>avedriftdwn := hist(ma(driftdwn,250,s),1); {average amount drifts down over last 250 periods}</div><div>sd_driftdwn := hist(stdev(driftdwn,250),1); {st dev amount drifts down over last 250 periods}</div><div>extremdriftdwn :=avedriftdwn+(sd_driftdwn*sdfactor)*-1;</div><div><br></div><div>&#091;color=darkgreen&#093;</div><div>&#091;fillstyle=solid&#093;</div><div>drift&gt;=driftma;</div><div><br></div><div>&#091;color=red&#093;</div><div>&#091;fillstyle=solid&#093;</div><div>drift&lt;driftma;</div><div><br></div><div>&#091;color=white&#093;</div>]]>
   </description>
   <pubDate>Tue, 25 Jul 2017 17:27:13 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3530#3530</guid>
  </item> 
  <item>
   <title>Problem averaging only positive values : Thank you very kindly for your...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3529#3529</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=196" rel="nofollow">cudderbean</a><br /><strong>Subject:</strong> 1012<br /><strong>Posted:</strong> 20&nbsp;Jun&nbsp;2017 at 9:07pm<br /><br />Thank you very kindly for your help.<div><br><div>That neat little function "undefined" does the trick. I have a feeling I have come across this problem before in other coding, so with your help solving it, it opens up more coding possibilities for me.</div><div><br></div><div>I am travelling at the moment, but when I get back to Aus, I will post the completed code for my indicator above.</div><div><br></div><div>Thanks again.</div></div>]]>
   </description>
   <pubDate>Tue, 20 Jun 2017 21:07:27 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3529#3529</guid>
  </item> 
  <item>
   <title>Problem averaging only positive values : Please try undefined.drift :=...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3528#3528</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=1" rel="nofollow">administrator</a><br /><strong>Subject:</strong> 1012<br /><strong>Posted:</strong> 20&nbsp;Jun&nbsp;2017 at 10:54am<br /><br /><div><p style="margin: 0px 0px 8px; text-overflow: ellipsis; word-wrap: break-word; color: rgb77, 77, 77; font-family: &quot;Helvetica Neue&quot;, Arial, Helvetica, sans-serif; font-size: 14px;">Please try undefined.</p><p style="margin: 0px; text-overflow: ellipsis; word-wrap: break-word; color: rgb77, 77, 77; font-family: &quot;Helvetica Neue&quot;, Arial, Helvetica, sans-serif; font-size: 14px;">drift := if(C&gt;cma,c-cma,undefined);</p></div>]]>
   </description>
   <pubDate>Tue, 20 Jun 2017 10:54:27 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3528#3528</guid>
  </item> 
  <item>
   <title>Problem averaging only positive values : I am trying to create an indicator...</title>
   <link>http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3527#3527</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.bullcharts.com.au/forum/member_profile.asp?PF=196" rel="nofollow">cudderbean</a><br /><strong>Subject:</strong> 1012<br /><strong>Posted:</strong> 01&nbsp;Jun&nbsp;2017 at 10:02pm<br /><br /><div>I am trying to create an indicator that measures how far the close is drifting away from the simple 10 day moving average of the close. So that I can see when the close <i>may </i>(?!) be drifting too far away from the mean.</div><div><br></div><div>&#091;target=default&#093;</div><div><br></div><div>cma:= ma(c,10,simple);</div><div>drift := c-cma;</div><div>avedrift := ma(drift,250,s); {average amount it drifts away over last 250 periods}</div><div><br></div><div>&#091;horzline=0&#093;</div><div><br></div><div>&#091;color=blue&#093;</div><div>drift;</div><div>&#091;color=red&#093;</div><div>avedrift;</div><div><br></div><div>Try this coding out on WPL for previous 250 days up until 19 May 2017.</div><div><br></div><div>The average drift away appears as .098</div><div><br></div><div>The PROBLEM is that the code is <b>also including</b> in its calculations <b>negative values</b> where the close also drifts away <b>below </b>the average...where c-cma returns a value less than zero.</div><div><br></div><div>I need the code to calculate how far the bull drift tends to move upwards away <b>ONLY </b>when the close is positive above the average.&nbsp;</div><div><br></div><div>When I use Excel to calculate ONLY the positive values<b> &gt;= the average</b>, the average becomes quite different &nbsp; &nbsp; .482 &nbsp; &#091;and .89 when you add a standard deviation&#093;</div><div><br></div><div>So I substituted these lines:</div><div>drift := if(c&gt;=cma,c-cma,cma-c);</div><div>drift := if(c&gt;=cma,c-cma,0);</div><div>drift := if(c&gt;=cma,c-cma,abs(cma-c));</div><div><br></div><div>No good.</div><div><br></div><div>The problem is that the IF function in BC demands 3 arguments..if ( a, then b, otherwise c)</div><div>Whereas Excel technically may only demand 2 arguments:</div><div>if &nbsp; &nbsp; &nbsp;close&gt;cma, &nbsp; then close-cma, &nbsp; otherwise ""&#091;i.e. blank which is numerically different from zero&#093;</div><div><br></div><div>How can I get BC to calculate when averaging <b>only </b>the positive values above the MA</div><div><br></div><div>&#091;I do plan to add refinements like standard deviations to find true extremes, but the basic average is proving tricky...will post end result if successful with coding&#093;</div><div><br></div><div>Am I missing the obvious. Anyone with more coding experience, your help would be much appreciated.</div><div>Thank you.</div>]]>
   </description>
   <pubDate>Thu, 01 Jun 2017 22:02:42 +0000</pubDate>
   <guid isPermaLink="true">http://www.bullcharts.com.au/forum/forum_posts.asp?TID=1012&amp;PID=3527#3527</guid>
  </item> 
 </channel>
</rss>