logo
  • Home
  • Discussions
  • Files
  • Register
  • Login
Welcome Guest! To enable all features please Login or Register.
  • Forum
  • Active Topics
  • Search
  • Help
  • Login
  • Register
  Search Search

Notification

Icon
Error

OK


Discussions  »  Product and Service Development  »  Formula Assistance  »  Candlestick Pattern Search
Candlestick Pattern Search - Candlestick Pattern Search
Options
  • Email this topic Email this topic
  • Watch this topic Watch this topic
  • Print this topic Print this topic
  • » Normal
  • Threaded
Go to last post Go to first unread
Previous Topic Next Topic
WmWaster  
#1 Posted : Tuesday, May 2, 2006 8:59:31 PM(UTC)
WmWaster

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/20/2006(UTC)
Posts: 53

Hi. 1) How can I search for candle pattern like the following: - a Bullish Harami occurred within the previous 5 days OR - at least 2 black candles occurred within the previous 5 days, being one lower than the other - no white candle breaks through the high of the first black candle within the previous 5 days - a big white candle was showed today Here's my trial:
Quote:
BarsSince(BullHarami()) <= 5 OR (BarsSince(Black()) <= 5 AND BarsSince(Black()) <= 5) {this code could not find what I want} AND {No idea how to code that line!} AND bigwhite()
As expected, it won't work. I couldn't think of any other altneratives to code my idea. 2) As to white() & bigwhite(), does anyone know how exactly Metastock define what candlestick is normal white body, which is big? Thank you.
Back to top
  • User Profile
  • View All Posts by User
  • View Thanks

Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.

Back to top  
wabbit  
#2 Posted : Wednesday, May 3, 2006 12:04:32 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
WmWaster wrote:
a Bullish Harami occurred within the previous 5 days OR
I would use the Alert function here in lieu of BarsSince(). I just think its a little neater and easier to read. It will have the same result: Alert(BullHarami(),5) OR
WmWaster wrote:
at least 2 black candles occurred within the previous 5 days, being one lower than the other
Use the Sum() function as a simple method to count how many time an event ocurred. When things get more complicated, using Sum() may not help so yuo need some more sophisticated tools in your toolbox. We are using the ValueWhen() function to compare the values of the LOW on the last and next-to-last time there was a black bar in the last five days. If there were more than two black bars in the last five days then we make sure that each LOW is lower than the previous. Sum(Black(),5)>=2 AND Sum(ValueWhen(1,Black(),L)<ValueWhen(2,Black(),L),5)>=2 AND
WmWaster wrote:
no white candle breaks through the high of the first black candle within the previous 5 days
All of the other criteria are relatively simple, except this one! You need a counter function to locate the first Black bar in the last five days. Thankfully Roy has this work for us: {Our thanks go to Roy Larsen} a:=Black(); {signal to count} b:=BarsSince(Black())>5; {signal to reset} i:=Cum(a+b>-1)=1; f:=BarsSince(i OR a)<BarsSince(i OR b); g:=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5))); counter:=If(f,g+1,g); Now the High of the first Black bar is: hi:=ValueWhen(1,counter=1,H); Now we need this to be the highest value in the five days: HHV(H,5)<=hi AND
WmWaster wrote:
a big white candle was showed today
So .... put all that together: --8<-------------------------------------------- {Our thanks go to Roy Larsen} a:=Black(); {signal to count} b:=BarsSince(Black())>5; {signal to reset} i:=Cum(a+b>-1)=1; f:=BarsSince(i OR a)<BarsSince(i OR b); g:=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5))); counter:=If(f,g+1,g); hi:=ValueWhen(1,counter=1,H); Alert(BullHarami(),5) OR Sum(Black(),5)>=2 AND Sum(ValueWhen(1,Black(),L)<ValueWhen(2,Black(),L),5)>=2 AND HHV(H,5)<=hi AND BigWhite() --8<-------------------------------------------- You might need to throw in some brackets around the functions to make sure the Boolean logic is correct: (x OR y) AND z, or x OR (y AND z).... etc Not a bad first attempt.... but my recommendation to you is, before you get too complicated in your trading systems, start very simply. There is nothing to be gained from piling indicator on indicator on indicator anyway, so keeping things very simple is often the best trading plan anyway! Hope this helps. Let me know if this works like it should. If it doesn't, a picture is worth a thousand words on where it is not performing. wabbit :D P.S. With the exception of Roy's little tricks, the rest of the information was gleaned from the MS Users Manual, which I have sitting next to me whenever I am at the computer.
Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
WmWaster  
#3 Posted : Sunday, May 7, 2006 3:15:16 PM(UTC)
WmWaster

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/20/2006(UTC)
Posts: 53

wabbit wrote:
WmWaster wrote:
a Bullish Harami occurred within the previous 5 days OR
I would use the Alert function here in lieu of BarsSince(). I just think its a little neater and easier to read. It will have the same result: Alert(BullHarami(),5) OR
Thanks for the alternative. OK I try to test these 2 functions. Here's what I type in each column in exploration: ======================== Col A: Alert(Black(),2) Col B: BarsSince(Black()) <= 2 Col C: BarsSince(Black()) Filter enabled Yes Periodicity Daily Records required 9 ======================== Here's what I found: 1) Alert: It includes today. Eg: "Alert(x,2)" refers to the time period of yerterday and today. Barsince: It excludes today. Eg: "BarSince(x) <= 2" refers to the time period of yesterday and "day before yersterday" Do I get it right? (Updated: I've checked this many times in different days. It should be right. I'll not be fooled by randonness!) 2) [Solved] I don't know why. Alert is fine, but Barsince returns "N/A" for some of the stocks. All stocks have at least 9 records. All have at least a black candle. Solution: I note that the abovementioned problem occurs because I've selected "Load Minimum Records" in Explorer Option, in which it auto select to load 9 days only. If I set to load more records, the problem is solved.
Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
WmWaster  
#4 Posted : Wednesday, May 10, 2006 3:05:32 PM(UTC)
WmWaster

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/20/2006(UTC)
Posts: 53

Quote:
Sum(Black(),5)>=2 AND Sum( ValueWhen(1,Black(),L) < ValueWhen(2,Black(),L) ,5) >=2
I think this formula can be simplified as: Sum(Black(),5)>=2 AND ( ValueWhen(1,Black(),L) < ValueWhen(2,Black(),L) ) It's because if it can pass the first condition, it can pass this condition Sum(x<x, 5) >=2 as well. So I don't think it's necessary, right?
Quote:
{Our thanks go to Roy Larsen} a:=Black(); {signal to count} b:=BarsSince(Black())>5; {signal to reset} i:=Cum(a+b>-1)=1; f:=BarsSince(i OR a)<BarsSince(i OR b); g:=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5))); counter:=If(f,g+1,g); hi:=ValueWhen(1,counter=1,H);
This one is very complex. One question: What's the point of: i:=Cum(a+b>-1)=1; g=Cum(a OR Cross(a,0.5))-ValueWhen(1,i OR (f AND Alert(f=0,2)) OR (f=0 AND Alert(f,2)),Cum(a OR Cross(a,0.5))); As to sum & cum function, is it true that: - they are to calculate the total of something - but we can specify the lookback period (inc today) for sum - while it is set to take the whole period into account for cum ?? I think the above is the only difference between this 2 functions.
Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
wabbit  
#5 Posted : Wednesday, May 10, 2006 11:13:46 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
The code just "initialses" the system. Plot the 'i' indicator on your chart to see it in action. wabbit :D
Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
WmWaster  
#6 Posted : Monday, May 22, 2006 2:47:18 PM(UTC)
WmWaster

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/20/2006(UTC)
Posts: 53

wabbit wrote:
The code just "initialses" the system. Plot the 'i' indicator on your chart to see it in action. wabbit :D
I don't know. I pasted the "i" indicator but it's empty. I still can't get the code. I don't see the points of havng i and f.
Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
wabbit  
#7 Posted : Tuesday, May 23, 2006 12:39:36 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Plot this indicator, a:=Black(); {signal to count} b:=BarsSince(Black())>5; {signal to reset} i:=Cum(a+b>-1)=1; i; and have a look at the very LEFT hand side of the chart. The indicator is undefined for a short period while both 'a' and 'b' are undefined , then 1 when 'i' initialises. After then, we can look for the 'a' and 'b' conditions so we let the value of 'i' fall to zero. This was Roy's ingenuity that makes this work. He wrote an excellent article in his MSTT newsletter to accompany it. If you get in touch with him, you can subscribe to his newsletter and get the back issues. He might even spot you a copy if you ask him really nicely. wabbit :D
Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
Users browsing this topic
Guest (Hidden)
Discussions  »  Product and Service Development  »  Formula Assistance  »  Candlestick Pattern Search
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2025, Yet Another Forum.NET
  • Terms
  • Privacy Statement
  •  
© Copyright 2025 MetaStock. All rights reserved.