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?
|
|
|
|
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]
|
|
|
|
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.
|
|
|
|
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()));
|
|
|
|
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]
|
|
|
|
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);
|
|
|
|
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.