Discussions
»
Product and Service Development
»
Formula Assistance
»
Examining lowest value in different time frames [RESOLVED]
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Can anyone tell me how I can find the lowest low value in the time frames below? I need to find the low for each time period.
Day1:=Dayofweek()>0;
Time1:=If(hour()>=00 AND hour()<=8 AND Day1,1,0);
Time2:=If(hour()>=9 AND hour()<=16 AND Day1,2,0);
Time3:=If(hour()>=17 AND hour()<24 AND Day1,3,0);
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
Not sure what day1 does ...
Anyways a quick answer would be for time one:
ValueWhen(1,Hour()=8 and Minute()=0,LowestSince(1,Hour()=0 and minute()=0,L))
Patrick :mrgreen:
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Thanks Pat,
Day1 is just a place holder right now until I figure out what days I want to trade on.
I'm not sure if this setup would work Pat I guess I didn't explain it clear enough. What I want to do is use the time session Time1, Time2, and Time3 to get the lowest low from the following session.
ex.- If I'm trading in session 1 or Time1 I want to know the lowest loe from Time3 and if I'm trading in Session 2 or Time2 I want to use the lowest low from session 1 or Time1.
Is this possible?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
Try something like that ...
Day1:=Dayofweek()>0;
Time1:=hour()>=00 AND hour()<=8 AND Day1;
Time2:=hour()>=9 AND hour()<=16 AND Day1;
Time3:=hour()>=17 AND hour()<24 AND Day1;
V1:=ValueWhen(1,Hour()=8 and Minute()=0,LowestSince(1,Hour()=0 and minute()=0,L));
V2:=ValueWhen(1,Hour()=16 and Minute()=0,LowestSince(1,Hour()=8 and minute()=0,L));
V3:=ValueWhen(1,Hour()=24 and Minute()=0,LowestSince(1,Hour()=17 and minute()=0,L));
if(Time1, V3,
if(Time2,V1,V2))
Patrick :mrgreen:
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
I didn't get anything when I ploted this one the chart Pat
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
I don't have a real time version up and running on this machine, could you plot and line one at the time and make sure that each one return something.
So that can we can find where the problem stands.
For example plot :
Dayofweek()>0
Make sure it goes to 1 at least once.
Then plot
Day1:=Dayofweek()>0;
Time1:=hour()>=00 AND hour()<=8 AND Day1;
Time1
Make sure it goes to 1 at least once.
etc ...
Thanks.
Patrick :mrgreen:
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Pat,
I ploted the time frame on a chart.
|
|
|
|
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)
|
Have you tried...
Day1:=Dayofweek()>0;
TradingSession:=If(hour()>=00 AND hour()<=8,1,if(hour()>=9 AND hour()<=16 ,2,3));
Day1 and lowestsince(1,TradingSession<>Ref(TradingSession,-1),L)
If that doesnt work for you, i will have another look tonight
wabbit :D
|
|
|
|
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)
|
{Second Edit}
Day1:=DayOfWeek()>0;
TradingSession:=If(Hour()>=00 AND Hour()<=8,1,If(Hour()>=9 AND Hour()<=16 ,2,3));
{auto scale the session indicator}
LVLL:=LastValue(Lowest(L));
LVHH:=LastValue(Highest(H));
Middle:=(LVHH+LVLL)/2;
{plot the session indicator}
If(TradingSession=1,LVLL,If(TradingSession=2,Middle,LVHH));
{plot the lowest value this session}
If(day1,LowestSince(1,TradingSession<>Ref(TradingSession,-1),L),0);
How's this looking for you?
wabbit :D
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
This is what I got Wabbit from your second edit. Its pretty close but I think I'm not explaining it right. I hope this next jpeg helps.
|
|
|
|
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)
|
OK... will have another crack tonight when I get home from work....
I am pretty sure I have a way to do this.
wabbit :D
|
|
|
|
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)
|
[edited... because I could]
Hope this does the trick....
It was an interesting project.
---8<----------------------------------
Day1:=DayOfWeek()>0;
TradingSession:=If(Hour()>=00 AND Hour()<=8,1,If(Hour()>=9 AND Hour()<=16 ,2,3));
{auto scale the session indicator}
LVLL:=LastValue(Lowest(L));
LVHH:=LastValue(Highest(H));
Middle:=(LVHH+LVLL)/2;
{plot the session indicator}
If(TradingSession=1,LVLL,If(TradingSession=2,Middle,LVHH));
x0:=TradingSession<>Ref(TradingSession,-1);
x1:=BarsSince(x0 OR Cum(x0>-1)=1);
{the lowest value this session}
LowThisSession:=LowestSince(1,x1=0,L);
LowThisSession;
{the lowest low in the last session}
LowLastSession:=ValueWhen(1,x1=0,Ref(LowThisSession,-1));
If(Cum(x0)>1,LowLastSession,lowThisSession);
---8<----------------------------------
wabbit :D
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Thanks Wabbit,
That worked fine I'll have to do some more review of the code later when I get off work.
Quick question thou can i used the same code to do the high also or is it an easier way to encode it with this code right?
|
|
|
|
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)
|
Somehow, in the back of my mind, I knew you were going to ask that.....
---8<-------------------------------------
{the highest value this session}
HiThisSession:=HighestSince(1,x1=0,H);
HiThisSession;
{the highest high in the last session}
HiLastSession:=ValueWhen(1,x1=0,Ref(HiThisSession,-1));
If(Cum(x0)>1,HiLastSession,HiThisSession);
---8<-------------------------------------
should work for you....
wabbit :D
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Thanks Wabbit,
This project has been a workout I know. I really need to get a better understanding of that latch system. Its the only true thing that holding me back I know.
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Examining lowest value in different time frames [RESOLVED]
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.