logo
Welcome Guest! To enable all features please Login or Registers.

Notification

Icon
Error

Options
Go to last post Go to first unread
Benny  
#1 Posted : Tuesday, June 6, 2006 6:47:00 AM(UTC)
Benny

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/23/2006(UTC)
Posts: 22
Location: Melbourne, Australia

Hello everyone, I am in need of some help. What I am wanting to do is get a exploration code for this indicator formula LowL:=If(LOW=LLV(LOW,5),LOW,If(Ref(LOW,-1)=LLV(LOW,5),Ref(LOW,-1), If(Ref(LOW,-2)=LLV(LOW,5),Ref(LOW,-2),If(Ref(LOW,-3)=LLV(LOW,5),Ref(LOW,-3), If(Ref(LOW,-4)=LLV(LOW,5),Ref(LOW,-4),0))))); NewH:=ValueWhen(1,HIGH>Ref(HHV(HIGH,5),-1),HIGH); box1:=HHV(HIGH,3)<HHV(HIGH,4); box2:=ValueWhen(1,BarsSince(HIGH>Ref(HHV(HIGH,5),-1))=3 AND box1=true,NewH); box3:=ValueWhen(1,BarsSince(HIGH>Ref(HHV(HIGH,5),-1))=3 AND box1=true,LowL); TopBox:=box2; BottomBox:=box3; TopBox; BottomBox; all I want it to do is pick out stocks that have just closed above the upper line and mark them with a + or just below the lower line and mark them with a - I guess a filter that discounts the stock with no signal would also help. Please if anyone has this code or is able to code it for me I would be very happy. Thank you.
wabbit  
#2 Posted : Tuesday, June 6, 2006 7:01:34 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)
I would start by breaking your code into the top of the box and the bottom of the box. Place each of these in the relevant exploration columns: {ColA} {Breakout of Darvas Top} NewH:=ValueWhen(1,HIGH>Ref(HHV(HIGH,5),-1),HIGH); box1:=HHV(HIGH,3)<HHV(HIGH,4); BoxTop:=ValueWhen(1,BarsSince(HIGH>Ref(HHV(HIGH,5),-1))=3 AND box1=true,NewH); x:=C>BoxTop; x AND Alert(x=0,2); {ColB} {Falling through Darvas Bottom} LowL:=If(LOW=LLV(LOW,5),LOW,If(Ref(LOW,-1)=LLV(LOW,5),Ref(LOW,-1),If(Ref(LOW,-2)=LLV(LOW,5),Ref(LOW,-2),If(Ref(LOW,-3)=LLV(LOW,5),Ref(LOW,-3), If(Ref(LOW,-4)=LLV(LOW,5),Ref(LOW,-4),0))))); box1:=HHV(HIGH,3)<HHV(HIGH,4); BoxBottom:=ValueWhen(1,BarsSince(HIGH>Ref(HHV(HIGH,5),-1))=3 AND box1=true,LowL); x:=C<BoxBottom; x AND Alert(x=0,2); Now all you have to do is filter for a 1 in Column A (the close went above the top of the box today, but was below the top of the box yesterday) or a 1 in Column B (the close is below the bottom of the box today, but was above the bottom of the box yesterday). {Filter} ColA>0 OR ColB>0 Hope this helps. wabbit :D
Benny  
#3 Posted : Tuesday, June 6, 2006 7:11:38 AM(UTC)
Benny

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/23/2006(UTC)
Posts: 22
Location: Melbourne, Australia

Thanks wabbit, You are a great help and have made me happy, also thanks for the super fast reply. :D
wabbit  
#4 Posted : Tuesday, June 6, 2006 7:29:49 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)
BTW - the Darvas Box formulas can be simplified somewhat.... --8<---------------------------- Hc:=BarsSince(H>Ref(HHV(H,5),-1))=3 AND HHV(H,3)<HHV(H,4); BoxTop:=ValueWhen(1,Hc,HHV(H,5)); {plot} BoxTop; --8<---------------------------- and --8<---------------------------- Hc:=BarsSince(H>Ref(HHV(H,5),-1))=3 AND HHV(H,3)<HHV(H,4); BoxBottom:=ValueWhen(1,Hc,LLV(L,5)); {plot} BoxBottom; --8<---------------------------- so the whole lot together makes, if I am not mistaken: --8<---------------------------- {Darvas Boxes} {recoded by wabbit 06/06/06 - just gotta love this date!} Hc:=BarsSince(H>Ref(HHV(H,5),-1))=3 AND HHV(H,3)<HHV(H,4); BoxTop:=ValueWhen(1,Hc,HHV(H,5)); BoxBottom:=ValueWhen(1,Hc,LLV(L,5)); {plot} BoxTop; BoxBottom; --8<---------------------------- I am pretty sure that they could be simplified further, but I didn't play with them for too long, and I don't want to! wabbit :D P.S. NEVER take someone else's code at face value. ALWAYS read and understand each and every line to see if it makes sense.
Benny  
#5 Posted : Tuesday, June 6, 2006 10:39:10 AM(UTC)
Benny

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/23/2006(UTC)
Posts: 22
Location: Melbourne, Australia

Hi again wabbit, I am stumped and I cant figure out what the problem is but when I run the exploration in the rejects area it shows alot of stocks that say Filter reference to N/A value in column A. I decided to open a chart on one of them (ARQ) and it appears that ARQ is showing a short signal but as you can tell from what I have said it is not coming up as a short in the exploration. Do you know what could be causing this, is it something in the code or is it somthing I just have to put up with? Thanks in advance.
wabbit  
#6 Posted : Tuesday, June 6, 2006 11:05:09 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)
Benny, Uncheck "load minimum records" and try again with at least 200 records loaded! Have a read through the forum for all the posts about this feature, and how many times it has brought people and explorations, unstuck. wabbit :D
Benny  
#7 Posted : Tuesday, June 6, 2006 11:14:54 AM(UTC)
Benny

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/23/2006(UTC)
Posts: 22
Location: Melbourne, Australia

Thank you so much Wabbit, that has made this much better for me now. I have also had the same problem with other explorations. Now that I know how it can be fixed gives me the same feeling as when you work really hard on something and it turns out great. I guess it must be the feeling of learning something new. Thanks again.
wabbit  
#8 Posted : Tuesday, June 6, 2006 11:29:05 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)
I suppose I should offer some more by ways of an explanation of what is happening... If I break a part the code for the boxes into: {ColA} {Darvas Boxes - Hi side breakout} Hc:=BarsSince(H>Ref(HHV(H,5),-1))=3 AND HHV(H,3)<HHV(H,4); BoxTop:=ValueWhen(1,Hc,HHV(H,5)); x:=C>BoxTop; x AND Alert(x=0,2); {ColB} {Darvas Boxes - Lo side breakout} Hc:=BarsSince(H>Ref(HHV(H,5),-1))=3 AND HHV(H,3)<HHV(H,4); BoxBottom:=ValueWhen(1,Hc,LLV(L,5)); x:=C<BoxBottom; x AND Alert(x=0,2); {Filter} ColA>0 OR ColB>0 In each condition, there is no 'initialisation' so for the filter to return a value BOTH Column A AND Column B criteria must return a value. If in the number of bars loaded in the exploration, Column A never happens OR Column B never happens then the result will be a NA rejection. To ensure the filter is accurate, you need to include enough history so that at least once in the loaded data, the close has been above the top of the box AND the close has been below the bottom of the box. The exploration will never return stocks where the close has been continuously inside the box, or has only ever escaped outside the box on one side only. If you want, you or someone else, could add an itialisation code. Roy Larsen is the expert at this, so check out his work in his latches code and apply the same principles. Or you can just make sure you have enough data loaded! Hope this helps. wabbit :D P.S. Please make sure you fully understand the Boolean operators, AND, OR, NOT etc They are extremely important in the post above and throughout MS.
mazzyon  
#9 Posted : Saturday, June 30, 2007 1:47:06 PM(UTC)
mazzyon

Rank: Newbie

Groups: Registered, Registered Users
Joined: 6/30/2007(UTC)
Posts: 1

Dear Mr Wabbit,

Would you please to advice us, how to add filter, only for all time high stocks ?

Big tx & rgds.
Mazzyon.
amory  
#10 Posted : Saturday, June 30, 2007 6:10:43 PM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

Hi Mazzyon. as I understand the Darvas system, it goes on the attack when a stock rises above its one-year high. having previously tried to break thru on several occasions, and forming 'boxes' along the way. something like that. this would make your last question to Mr Wabbit very plausible.

myself, writing exploration the oldfashioned way, have always used the following line in my Darvas searches, in conjunction with various other criteria:

CLOSE>Ref(HHV(CLOSE,120),-1)

this will give me a break on today's close, thru the High for the last 6 months. I think mr Darvas would agree that things move faster these days & to ask for a 1-year high is excessive. anyway, the 120 can be changed to 250 which is one year's trading days.

perhaps you could ask mr Wabbit would he be kind enough to fit this into the formula somehow, then we shall both benefit. you could also include something with regard to minimum volume, in order to cut out a lot of low-liquidity junk.

P.S. as far as the Darvas system is concerned, I don't believe it made provision for the downside. except to the extent that mr Darvas worked to very strict Stoploss guidelines. that would have been in part at least, the secret of his success. maybe he kept an eye on a watch-list of potential break-thru candidates, in that case the formula as it stands, would be sufficient.

amory  
#11 Posted : Saturday, June 30, 2007 7:37:23 PM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

let me tell you what I consider to be the most difficult part of a Darvas exploration, in the spirit of its creator: the "previously tried (& failed) to break thru on several occasions" bit. if in addition, one could add something to the effect of successive higher low's during that period, one would have the perfect formula. keep trying!


wabbit  
#12 Posted : Sunday, July 1, 2007 11:42:43 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)
Amory has most of the situation covered wrt Darvas. If you want to only include the instances when the stock is making its all time high (for the data loaded) add the Highest() function to the filter condition; e.g

{Filter}
ColA>0 OR ColB>0
AND C=Highest(C);

or you could do the timeframe lookback like Amory has already displayed.


Hope this helps.

wabbit [:D]

Jose  
#13 Posted : Monday, July 2, 2007 3:07:16 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)

Below is an excellent Darvas signals indicator found within the Divergence kit's documentation at http://www.metastocktools.com/MACDH/MACDH.pdf:

===============

Darvas Box - Buy & Sell

===============

---8<------------------------------------

{ Darvas Box - Buy & Sell v1.0

Copyright © 2006-2007 Jose Silva.
For personal use only.
http://www.metastocktools.com }

{ User input }
pds:=Input("Lookback periods",2,2600,100);

{ Variables }
h3:=Ref(H,-3);
l3:=Ref(L,-3);
init:=Cum(IsDefined(Ref(HHV(H,pds),-4)))=1;

{ Darvas High }
DvHi:=ValueWhen(1,init OR
h3>=Ref(HHV(H,pds),-4) AND h3>HHV(H,3),h3);

{ New Darvas High }
NuDvHi:=Dvhi<>Ref(DvHi,-1);

{ New Darvas Low }
NuDvLo:=l3<LLV(L,3) AND DvHi>HHV(H,3);
NuDvLo:=NuDvLo AND Ref(NuDvLo,-1)<1
AND Cum(NuDvHi)>0;

{ Darvas Low }
DvLo:=ValueWhen(1,NuDvLo,l3);

{ Darvas Box End }
DvEnd:=
BarsSince(NuDvHi)<BarsSince(Ref(NuDvLo,-1));
DvEnd:=(DvEnd AND NuDvLo)
OR Cum(IsDefined(DvEnd))=1;

{ Darvas Box High }
DvBoxHi:=ValueWhen(1,DvEnd,DvHi);

{ Darvas Box Low }
DvBoxLo:=ValueWhen(1,DvEnd,DvLo);

{ Darvas Possible Sell }
DvPosSell:=L<DvBoxLo AND Alert(L<DvBoxLo=0,2);

{ Darvas Sell }
exit:=BarsSince(DvEnd)<BarsSince(DvPosSell);
exit:=exit=0 AND Alert(exit,2)
OR Cum(IsDefined(exit))=1;

{ Darvas Buy }
{ Classic Darvas: change next line to H>DvBoxHi}

entry:=C>DvBoxHi
AND BarsSince(DvEnd)<BarsSince(exit);

{ Clean signals }
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2) OR init);
short:=(bin=0)*(Alert(bin,2) OR init);

{ Plot in own window }
long-short

---8<------------------------------------

MACDH/All-In-One Divergence kit :

http://www.metastocktools.com/MACDH/MACDHdiverg.htm

jose '-)

amory  
#14 Posted : Monday, July 2, 2007 4:04:28 AM(UTC)
amory

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/18/2007(UTC)
Posts: 99
Location: sydney australia

as usual, spot-on Jose! on chart, indicates not just any old entries, but specifically when they fit into a Darvas pattern. it's a top indicator alright.

when signaling 'exit', could mean part of a new box-formation leading to better things, or just that: exit, get out, it didn't work! I do believe old Darvas worked with a very tight stop-loss, something like 2%. no benefit of the doubt there!

thanks Wabbit and Jose, for clearing that one up.

Users browsing this topic
Guest (Hidden)
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.