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

Notification

Icon
Error

Options
Go to last post Go to first unread
Bullstock  
#1 Posted : Friday, May 30, 2008 8:03:11 PM(UTC)
Bullstock

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/28/2006(UTC)
Posts: 32

With reference to the Intraday Bar Counter, http://forum.equis.com/forums/thread/26312.aspx

I would like to identify the "first" highest high for the day.

{Intraday Bar Counter}

D:=DayOfMonth();

FirstBar:=Cum(1)=1;

NewDay:=ExtFml("Forum.Sum",D<>Ref(D,-1),1);

IBC:=1 + BarsSince(FirstBar OR NewDay);

A:=HighestSince(NewDay);

B:=ValueWhen(1,H=A,IBC);

B=IBC

I have attempted, but it only identify the first occurance from the current bar, and I want to identify the "first" highest high. Can anyonehelp me?

Bullstock

wabbit  
#2 Posted : Saturday, May 31, 2008 12:12:54 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)
The identification of a new day is different, but you can customise the concept at : http://forum.equis.com/forums/thread/27186.aspx
Bullstock  
#3 Posted : Sunday, June 1, 2008 9:05:00 PM(UTC)
Bullstock

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/28/2006(UTC)
Posts: 32

Wabbit,

Thanks for your help.

Well, my aim is to identify the "First Highest High Bar" for the day in an intraday chart.

Take the following example:

NDay O H L C

Bar 1 100 101 100 100

Bar 2 100 110 100 105

Bar 3 105 105 90 90

Bar 4 90 95 90 95

Bar 5 95 110 95 100

Bar 6 100 100 90 95

The highest high is 110 on "Bar 2" and "Bar 5", I want to code an indicator to give a signal on "Bar 2". I have tried the following:-

{identify the start of the trading day}

newDay:=DayOfMonth()<>Ref(DayOfMonth(),-1) OR Cum(1)=2;

{find the highest high so far this trading day}

HH:=HighestSince(1,newDay,H);

HH:=LastValue(HH);

H=HH

It returns 2 signals on Bar 2 and 5. how can I make it signalling Bar 2 only?

Bullstock

wabbit  
#4 Posted : Sunday, June 1, 2008 9:59:35 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)
Hi Bullstock,

Use the count and reset code as hsown in the example on the other post.


wabbit [:D]

Bullstock  
#5 Posted : Friday, June 6, 2008 3:54:22 AM(UTC)
Bullstock

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/28/2006(UTC)
Posts: 32

I still can't do that. can anyone help me?

Bullstock

wabbit  
#6 Posted : Friday, June 6, 2008 6:33: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)
How far did you get with your code?

Try this....

Code:
{identify the start of the trading day}
newDay:=DayOfMonth()<>Ref(DayOfMonth(),-1) OR Cum(1)=2;

{find the highest high so far this trading day}
highestHigh:=HighestSince(1,newDay,H);

{find new highest high}
hh:=H>Ref(HighestHigh,-1);

{count and reset}
count:=Cum(hh);
reset:=newDay;
counter:=count - ValueWhen(1,reset,count);

{signal/alert}
counter=1 AND Alert(counter<>1,2);



Hope this helps.

wabbit [:D]

Bullstock  
#7 Posted : Saturday, June 7, 2008 5:13:30 PM(UTC)
Bullstock

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/28/2006(UTC)
Posts: 32

Wabbit,

Thanks for your help, but it doesn't show the "first" highest high bar. It in fact shows the first bar.

I use the following data as an example:-

05/30/2008 9:59:000 85.0000 90.0000 85.0000 90.0000
05/30/2008 10:00:000 95.0000 96.0000 95.0000 95.0000
05/30/2008 10:01:000 95.0000 105.000 95.0000 100.000
05/30/2008 10:02:000 100.000 100.000 85.0000 85.0000
05/30/2008 10:03:000 85.0000 90.0000 85.0000 90.0000
05/30/2008 10:04:000 90.0000 105.000 90.0000 95.0000
05/30/2008 10:05:000 95.0000 95.0000 85.0000 90.0000
06/02/2008 9:59:000 90.0000 95.0000 90.0000 95.0000
06/02/2008 10:00:000 100.000 101.000 100.000 100.000
06/02/2008 10:01:000 100.000 110.000 100.000 105.000
06/02/2008 10:02:000 105.000 105.000 90.0000 90.0000
06/02/2008 10:03:000 90.0000 95.0000 90.0000 95.0000
06/02/2008 10:04:000 95.0000 110.000 95.0000 100.000
06/02/2008 10:05:000 100.000 100.000 90.0000 95.0000

When I plot hh, it plots the 1st and 2nd bars, but it should plots bar 2 & 5.

Bullstock

wabbit  
#8 Posted : Saturday, June 7, 2008 9:19:32 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)
With the small dataset you have given, going through it manuially, using the code as I have posted previously, these are the results I get:

1 05/30/2008 09:59:000 85.0000 90.0000 85.0000 90.0000 FIRST BAR NULL
2 05/30/2008 10:00:000 95.0000 96.0000 95.0000 95.0000 newDay
3 05/30/2008 10:01:000 95.0000 105.000 95.0000 100.000 highestHigh << first new highestHigh on this day
4 05/30/2008 10:02:000 100.000 100.000 85.0000 85.0000
5 05/30/2008 10:03:000 85.0000 90.0000 85.0000 90.0000
6 05/30/2008 10:04:000 90.0000 105.000 90.0000 95.0000
7 05/30/2008 10:05:000 95.0000 95.0000 85.0000 90.0000
8 06/02/2008 09:59:000 90.0000 95.0000 90.0000 95.0000 newDay
9 06/02/2008 10:00:000 100.000 101.000 100.000 100.000 highestHigh << first new highestHigh on this day
10 06/02/2008 10:01:000 100.000 110.000 100.000 105.000 highestHigh
11 06/02/2008 10:02:000 105.000 105.000 90.0000 90.0000
12 06/02/2008 10:03:000 90.0000 95.0000 90.0000 95.0000
13 06/02/2008 10:04:000 95.0000 110.000 95.0000 100.000
14 06/02/2008 10:05:000 100.000 100.000 90.0000 95.0000

so the function should be returning TRUE values on bars 3 and 9, FALSE otherwise. The reason that bar 2 is not captured is because of the NULL first bar.

Changing the code to use the external function to remove the NULL first bar, and trap the first counter gives results same as the manual identification of bars as follows:

1 05/30/2008 09:59:000 85.0000 90.0000 85.0000 90.0000 newDay
2 05/30/2008 10:00:000 95.0000 96.0000 95.0000 95.0000 first highestHigh << first new highestHigh on this day
3 05/30/2008 10:01:000 95.0000 105.000 95.0000 100.000 new highestHigh
4 05/30/2008 10:02:000 100.000 100.000 85.0000 85.0000
5 05/30/2008 10:03:000 85.0000 90.0000 85.0000 90.0000
6 05/30/2008 10:04:000 90.0000 105.000 90.0000 95.0000 revisit highestHigh
7 05/30/2008 10:05:000 95.0000 95.0000 85.0000 90.0000
8 06/02/2008 09:59:000 90.0000 95.0000 90.0000 95.0000 newDay
9 06/02/2008 10:00:000 100.000 101.000 100.000 100.000 first highestHigh << first new highestHigh on this day
10 06/02/2008 10:01:000 100.000 110.000 100.000 105.000 new highestHigh
11 06/02/2008 10:02:000 105.000 105.000 90.0000 90.0000
12 06/02/2008 10:03:000 90.0000 95.0000 90.0000 95.0000
13 06/02/2008 10:04:000 95.0000 110.000 95.0000 100.000 revisit highestHigh
14 06/02/2008 10:05:000 100.000 100.000 90.0000 95.0000


Code:
{identify the start of the trading day, or start of chart}
newDay:=ExtFml("Forum.Sum",DayOfMonth()<>Ref(DayOfMonth(),-1),1) OR Cum(1)=1;

{find the highest high so far this trading day}
highestHigh:=HighestSince(1,newDay,H);

{find a new highest high}
hh:=ExtFml("Forum.sum",H>Ref(HighestHigh,-1),1) OR newDay;

{count and reset}
count:=Cum(hh);
reset:=newDay;
counter:=count - ValueWhen(1,reset,count);

{signal/alert}
counter=1 AND Alert(counter<>1,2);


If this doesn't work for you, let me know.


wabbit [:D]

Bullstock  
#9 Posted : Sunday, June 8, 2008 10:04:36 AM(UTC)
Bullstock

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/28/2006(UTC)
Posts: 32

Hi Wabbit,

I may have not expressed it clearly, I want the code to plot a signal for the first highest high

1 05/30/2008 09:59:000 85.0000 90.0000 85.0000 90.0000 newDay
2 05/30/2008 10:00:000 95.0000 96.0000 95.0000 95.0000 first highestHigh << first new highestHigh on this day
3 05/30/2008 10:01:000 95.0000 105.000 95.0000 100.000 new highestHigh
4 05/30/2008 10:02:000 100.000 100.000 85.0000 85.0000
5 05/30/2008 10:03:000 85.0000 90.0000 85.0000 90.0000
6 05/30/2008 10:04:000 90.0000 105.000 90.0000 95.0000 revisit highestHigh
7 05/30/2008 10:05:000 95.0000 95.0000 85.0000 90.0000
8 06/02/2008 09:59:000 90.0000 95.0000 90.0000 95.0000 newDay
9 06/02/2008 10:00:000 100.000 101.000 100.000 100.000 first highestHigh << first new highestHigh on this day
10 06/02/2008 10:01:000 100.000 110.000 100.000 105.000 new highestHigh
11 06/02/2008 10:02:000 105.000 105.000 90.0000 90.0000
12 06/02/2008 10:03:000 90.0000 95.0000 90.0000 95.0000
13 06/02/2008 10:04:000 95.0000 110.000 95.0000 100.000 revisit highestHigh
14 06/02/2008 10:05:000 100.000 100.000 90.0000 95.0000

As of the last bar say for Jun 2 as show in the above data, there are two highest highs for the day (bar 10:01 and bar 10:04), I want the code to plot on the first on 10:01. (If there is only one highest high, jsut plot on it. If there are three highest highs, plot on the first one..... )

However, you code plots both a signal on bar 10:00.

Regards,

Bullstock

Bullstock  
#10 Posted : Friday, June 13, 2008 4:28:01 AM(UTC)
Bullstock

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/28/2006(UTC)
Posts: 32

Dear Wabbit,

Could you help me to correct it?.... I think the porblem is that hh will count for the bar in which it doesn't match with my requirement, but I need the highest high bar(s) as of the most recent bar.

hh:=H>Ref(HighestHigh,-1);

hh will also count for the bar that is not the "highest high" bar as of the most recent bar.

I think of using lastvalue, but it doesn't seem working.

I can't think of any good method to handle it.

Regards,

Bullstock

wabbit  
#11 Posted : Friday, June 13, 2008 5:01:18 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)
Sorry about the disappearance for the last couple of days, I have been finishing exams...

If you want a system that is back-testable and which can be traded live then you need to use the code as it is provided. If you want to use hindsight then you will need to re-write the code and throw in a LastValue() (or two) but this will only be of use on the most current trading day.

There are ways to use an external function to trap the LastValue() features on a daily basis, but again this use of hindsight does not support live trading or backtesting.

If you want to discuss this more, contact me off the forum.


wabbit [:D]


PTJim  
#12 Posted : Sunday, June 15, 2008 2:31:04 PM(UTC)
PTJim

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/10/2006(UTC)
Posts: 252

Thanks: 11 times
Was thanked: 9 time(s) in 6 post(s)
You might give this a try; I haven't personally tested it. By inputting a value for "nth" you should be able to specify the Nth highest-high, not just the first but whichever you wish.

Code:
===================
Highs - Nth intraday signals
===================
---8<-------------------------------------------------

{ Plots:
Nth new highest High for day (+1 signal);
All new highest Highs for day (+0.3 signal).

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

{ Indicator input }
nth:=Input("Signal Nth new High",0,1440,1);

{ Start of trading day }
nuDay:=DayOfMonth()<>Ref(DayOfMonth(),-1)
OR Cum(1)=2;

{ Highest High since start of day }
hiHi:=HighestSince(1,nuDay,H);

{ Signal new highest High for each day }
nuHi:=hiHi>Ref(hiHi,-1) AND nuDay=0;

{ Count highest Highs for each day }
count:=Cum(nuHi)-ValueWhen(1,nuday,Cum(nuHi));

{ Signal Nth new High for day }
signal:=count=nth AND (nuHi OR nuDay);

{ Plot in own window }
nuHi*.3;signal

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

Here's the link to the code posting at Trader's Consortium.



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.