[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Normalized Chart of Last XX trading days



PureBytes Links

Trading Reference Links

Yes it can be done. Really what you are about to do is signal averaging minute data wrt an event, the event could be the start of the day, or a particular weekday, or a trading signal. You can do a search for "signal averaging" in the archives, i am sure i posted some code some years ago and i think there is an DLL in Yahoo files under my name. I am including some code below that averages up to four test values (you could use foreign() to access different stock data here).
 
I am sorry but i have no time to step you through the code... I haven't used it for a long time. Run it in an indicator on Minute data and you should see a display as show below, the Red and Blue are all daily charts Signal Averaged wrt the Open of the day, i.e. they are what it looks like if you overlay all the days in your DB and calculate the average for each minute bar's TestValue. The X-axis labeling is not used, the vertical lines are half-hour markers.
 
I hope the code will give you some ideas.
Good luck,
herman
 
 

Pd=Param("Pd",10,1,10,1);

NewDay = DateNum() != Ref(DateNum(),-1);

DailyBarNum = Nz(BarsSince(NewDay));

MaxDailyBarNum = LastValue(Highest(DailyBarNum));

NewDayNum = Cum(NewDay);

MaxDayNum = LastValue(Highest(NewDayNum));

FirstNewDayBarNum = LastValue(ValueWhen(NewDayNum == 0, BarIndex()));

BarNumAtNewDay = ValueWhen(NewDay, BarIndex());

StartLastWholeDay = LastValue(ValueWhen(NewDayNum == (MaxDayNum -1) AND NewDay, BarIndex()));

ValidData = Flip(NewdayNum == 1, NewDayNum == (MaxDayNum-1));

StartDisplay = StartLastWholeDay == BarIndex();

EndDisplay = BarsSince(StartDisplay) == 390;

DisplayRange = Flip(StartDisplay, EndDisplay);

TestValue1 = abs(C-O)/C*100;

Testvalue2 = (H-L)/C*100;

TestValue3 = Null;//abs(H-O)/C*100;

Testvalue4 = Null;//abs(O-L)/C*100;

Result1 = Result2 = Result3 = Result4 = 0;

 

for(b=0; b<BarCount-1 ; b++)

{

ResultIndex = Nz(StartLastWholeDay + DailyBarNum[b]) ;

Result1[ ResultIndex ] = Result1[ ResultIndex ] + ValidData[b] * TestValue1[b];

Result2[ ResultIndex ] = Result2[ ResultIndex ] + ValidData[b] * TestValue2[b];

Result3[ ResultIndex ] = Result3[ ResultIndex ] + ValidData[b] * TestValue3[b];

Result4[ ResultIndex ] = Result4[ ResultIndex ] + ValidData[b] * TestValue4[b];

}

MaxDisplay = LastValue(Highest(ValueWhen(DisplayRange,Result1)));

Plot(NOT DisplayRange ,"",1,styleOwnScale|styleArea|styleNoLabel);

Plot(Result1,"Result1",6,1|4|styleNoLabel);

Plot(Result2,"Result2",4,1|4|styleNoLabel);

Plot(Result3,"Result3",8,1|4|styleNoLabel);

Plot(Result4,"Result4",7,1|4|styleNoLabel);

Plot(NewDay ,"VD",1,2|styleOwnScale|styleNoLabel);

Plot(Cum(DisplayRange)%30==0,"",0,2|styleOwnScale|styleNoLabel);

GraphXSpace = 5;

 
-----Original Message-----
From: Rick [mailto:RickParsons@xxxxxxxxxxxxxxx]
Sent: Monday, January 31, 2005 7:25 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Normalized Chart of Last XX trading days


Here is a challenge:

I have seen normalized charts where several securities start at the
same starting point on the left and vary from that point on.

What I would like to do the same thing but I want to use one security
and normalize the last XX trading days on a chart.

For example, if this is Friday, I would like to see 4 normalized
lines, of the same secutiry.  One for Monday, one for Tues, one for
Wednesday, and one for Thursday.  Each line would start at 9:30am and
stop at 4:30pm.  This would be done on real time data down to 1
minute.

I would eventually like to enhance this to include only the last XX
Mondays, or only the last XX Tuesdays, etc.

It would be nice to have a parameter input so we can select a number
for "XX" days.

My goal is to study how the market trends from day to day and find
patterns.

I not experienced enought to figure out how to do this.  I actually
bet no one can do this!!  Prove me wrong.

Rick  :)







Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html




Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html




Yahoo! Groups Links