Print Page | Close Window

alltrue....

Printed From: BullCharts Forum
Category: BullCharts
Forum Name: BullScript
Forum Discription: Technical discussion related specifically to the BullScript programming language.
URL: http://www.bullcharts.com.au/forum/forum_posts.asp?TID=281
Printed Date: 19 May 2024 at 7:56am
Software Version: Web Wiz Forums 9.69 - http://www.webwizforums.com


Topic: alltrue....
Posted By: etrader
Subject: alltrue....
Date Posted: 10 Aug 2005 at 2:40pm

(alltrue(Close > hist(Close, 1),10))

this script is finding me any stocks that close higher 10 days in a row. If I use "anytrue" it would find me stocks that closed higher any of the 10 previous days. [this is only an easy way to explain the example, not a scan i use practically]

My question is: Can I script to find stocks that are "alltrue" as above, with the exception of 'any' 1 of the 10 days. In this case, 90% of the #days I am scanning must meet the criteria [ie. 9 out of 10 days are true].

Sometimes my scans feel too tight, and miss the odd good move. To capture these without increasing the output results too much, I think a solution as above might work for me...

cheers etrader




Replies:
Posted By: Tim Allen
Date Posted: 10 Aug 2005 at 5:23pm
I have to say, I'm glad you're not using that scan practically - you'd never buy anything! I had to tone it down to just 5 previous days in order to test my solution. :)

Anyway, something that might not be incredibly obvious: although a criterion such as "Close > hist(close, 1)" is a 'boolean' value, that is it can be either True or False, you can actually treat booleans as numbers: a True boolean value is equivalent to '1' and a False boolean value is equivalent to 0.

Thus, the script you're looking for is:

sum(Close > hist(Close, 1), 10) > 9;

The way it works is this:
  • it evaluates the condition "Close > hist(Close,1)" for each of the past 10 bars, returning a 'True' or 'False' for each of those.
  • it adds all those values together, which effectively gives you a count of the number of 'successes' found - the number of times your condition was found to be true.
  • it compares this count to your minimum number of successes (9).
I hope that all makes sense - coming from a maths/computer science background, sometimes I get caught up in the jargon and forget to explain myself properly. If you've got any questions, please ask!


Posted By: etrader
Date Posted: 10 Aug 2005 at 9:52pm

that is perfect, exactly how I was imagining, many thanks Tim.

etrader




Print Page | Close Window

Bulletin Board Software by Web Wiz Forums® version 9.69 - http://www.webwizforums.com
Copyright ©2001-2010 Web Wiz - http://www.webwiz.co.uk