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

Notification

Icon
Error

Options
Go to last post Go to first unread
andwilson  
#1 Posted : Monday, June 23, 2008 7:07:21 PM(UTC)
andwilson

Rank: Newbie

Groups: Registered, Registered Users
Joined: 6/6/2008(UTC)
Posts: 9

HI,

When I use the function hour() as the Data Array in function
valuewhen(Nth, Expression, Data Array), it always return the current hour
and not the hour when happen the condition.

In the example below it will always return 12, eventhough the lowest occured at
another hour.

res:=If(Hour()=12,Ref(LowestSince(1,Hour()=12,L),-1),0);
If(res=0,0,ValueWhen(1,C=res,Hour()));

What am I doing wrong? Anyone?
wabbit  
#2 Posted : Monday, June 23, 2008 8:13:08 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)
What is the explanation of what you are trying to achieve?

If my understanding of what you are trying to achieve is correct, you are looking to find the most recent time the CLOSE price was the same as the LOW price (and that price was a new low?) during Hour()=12 ?

In the first line, if Hour()=12 the first condition of the If() will be evaluated. Looking inside the Ref() we see the LowestSince(1,Hour()=12,L) will return the LOW price because the Hour() is currently 12. Expanding this out to now include the Ref(), we have Ref(L,-1), so the first line of code could be: res:=(Hour()=12) * Ref(L,-1); BUT lowestsince() will produce a different result on the first bar of the hour, intended or accidental??? Anyway, the point is that the first line of code will return either zero or a price from some time when the Hour()=12. The second line will always return a value of 12 because there is no other opportunity for the CLOSE price to equal the result of the first line of code unless the CLOSE=0.


wabbit [:D]

andwilson  
#3 Posted : Monday, June 23, 2008 8:24:08 PM(UTC)
andwilson

Rank: Newbie

Groups: Registered, Registered Users
Joined: 6/6/2008(UTC)
Posts: 9

res:=If(Hour()=12,Ref(LowestSince(1,Hour()=12,L),-1),0);

This line actually returns the lowest LOW since the last 12:00, and works corretly

My problem is with the second line

If(res=0,0,ValueWhen(1,C=res,Hour()));

Although res has the lowest value since the 12:00 and DID NOT occur at 12:00
I expected to get the hour when the lowest value occured
and not the current hour

In other words, I would like to graphically see if there is an hour of the day when the probability of a LOW is more common to occur.

andwilson  
#4 Posted : Monday, June 23, 2008 8:32:37 PM(UTC)
andwilson

Rank: Newbie

Groups: Registered, Registered Users
Joined: 6/6/2008(UTC)
Posts: 9

There was an error on second line, but even correcting it it still does not work

If(res=0,0,ValueWhen(1,LOW=res,Hour()));
wabbit  
#5 Posted : Monday, June 23, 2008 9:12:12 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)
try something like this on an hourly chart...

res:=Ref(LowestSince(1,Hour()=12,L),-1);
ValueWhen(1,LOW<=res,Hour())


wabbit [:D]

andwilson  
#6 Posted : Monday, June 23, 2008 9:23:29 PM(UTC)
andwilson

Rank: Newbie

Groups: Registered, Registered Users
Joined: 6/6/2008(UTC)
Posts: 9

Thanks, it worked, I only added an extra line so it only gives me a low a day

res:=Ref(LowestSince(1,Hour()=12,L),-1);
res2:=ValueWhen(1,LOW<=res,Hour());
if(Hour()=12,res2,0);
wabbit  
#7 Posted : Monday, June 23, 2008 9:24:55 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)
no probs....

have a great day!


wabbit [:D]

P.S. You can achieve the same last line:

if(Hour()=12,res2,0);

with

(Hour()=12) * res2;

which I think is a little easier to maintain?

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.