BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: alltrue....
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

alltrue....

 Post Reply Post Reply
Author
Message / View First Unread Post
etrader View Drop Down
Regular
Regular
Avatar

Joined: 18 Dec 2004
Posts: 63
Post Options Post Options   Quote etrader Quote  Post ReplyReply Direct Link To This Post Topic: alltrue....
    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



Edited by etrader
Back to Top
Tim Allen View Drop Down
BullCharts Staff
BullCharts Staff
Avatar

Joined: 10 Sep 2004
Location: Australia
Posts: 53
Post Options Post Options   Quote Tim Allen Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
etrader View Drop Down
Regular
Regular
Avatar

Joined: 18 Dec 2004
Posts: 63
Post Options Post Options   Quote etrader Quote  Post ReplyReply Direct Link To This Post Posted: 10 Aug 2005 at 9:52pm

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

etrader

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz