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

Notification

Icon
Error

Options
Go to last post Go to first unread
daiwa  
#1 Posted : Thursday, May 29, 2008 11:28:17 AM(UTC)
daiwa

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 8/27/2006(UTC)
Posts: 16
Location: Finland

Hello metastock programmers,
==================

I wonder what´s wrong in this line ?

It´s just simple 144 days range as high minus low multiplied by x .618
to know when issue occured.

Another issue, why use C - it´s close price only,
is there general input for all "O,H,L,C" day candle or
is it better to use peak or thogh function instead cross ?

{ColA - ElapsedBars}
x:=Cross(HHV(C,144)-(LLV(C,144)),C)*618;
BarsSince(x);

Any idea to mix this with Zig function ?

Regards,

-D


wabbit  
#2 Posted : Thursday, May 29, 2008 6:41:37 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)
Code:
x:=Cross(HHV(C,144)-(LLV(C,144)),C)*0.618;


I have taken the liberty to extract the condition inside the Cross() function for clarity, and rewritten the code as:

Code:
x:=HHV(C,144)-LLV(C,144);
y:=Cross(x,C)*0.618;


There is no issue with the first component. HHV()-LLV() of the same data set is going to return a value gte zero, which is the range of CLOSE prices in the period. If you want the range between the highs and lows, see later on for examples.

The next line shows the Cross() function, which returns values of zero (false) or 1 (true) based on the condition inside the brackets, so multiplying this 0.618 will return values of zero if the condition inside the cross did NOT occur, or 0.618 if the condition did occur.

I don't think this is the result you intended?

Also, look carefully at the range condition. Using the analogy on a single bar, the range of the bar is HIGH-LOW. If you are looking for a CLOSE in the lower portion of the bar, you do not test the CLOSE versus the RANGE, you test the CLOSE versus the LOW + (% x RANGE) e.g.

To find stocks closing below 0.618 of the days range:
Code:
range := HIGH - LOW;
targetPrice := LOW + (0.618 * range);
cond := C < targetPrice;
{plot}
cond;


In your case, the code should be something more akin to:

Code:
prd := 144;
range := HHV(H,prd)-LLV(L,prd);
targetPrice := LLV(L,prd) + (0.618 * range);
cond := Cross(targetPrice,C);
{plot}
barssince(cond);


Hope this helps.

wabbit [:D]

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.