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

[amibroker] Investigating the past events



PureBytes Links

Trading Reference Links




A.The Cross(0,MACD()) is an event.If I want to search 
the database for the last bar event, then I select Rangen=1 last quotations 
and explore with
 
<FONT 
size=2>Event=Cross(0,MACD());Filter=Event;AddColumn(C,"Close");AddColumn(BarsSince(Event),"Barssince",1.0);
 
In the results list I read the last bar Close. The 
"Barssince" column is full of zeros, as it should be.
 
B.I want now to explore the same event 5 bars ago.One 
solution is to select Range*from 22/9/2003 to 22/9/2003and explore with 
the same formula.I will read now the Closes of 22/9/2003 and the  
"Barssince" column will be zero again.It is simple, but I have to select 
manually the range.There are altenatives.
 
C.Range *all quotations and
 
Event=Cross(0,MACD());Filter=DateNum()==1030922 AND 
Event;AddColumn(C,"Close");AddColumn(BarsSince(Event),"Barssince",1.0);
 
The results will be similar to B.There is a minus in this 
alternative : The exploration for *all quotations may be time 
consuming.
 
D. If I imagine for a moment that 22/9/2003 is the last 
bar, then the rest are still unknown and I could explore again for the n=1 
last quotations.It may be executed by shifting all arrays by 5 bars. Then 
the 22/9/2003 will be in the place of 29/9/2003 and will be the last known 
bar.In AA selsect againRange *n=1 last quotations and explore 
with
 
<FONT 
size=2>Event=Cross(0,MACD());shift=5;C=Ref(C,-shift);ShiftedEvent=Cross(0,MACD());Filter=ShiftedEvent;AddColumn(C,"Shifted 
Close");AddColumn(BarsSince(ShiftedEvent),"Shifted 
Barssince",1.0);RestorePriceArrays();AddColumn(C,"Close");AddColumn(BarsSince(event),"Barssince",1.0);
 
The two first columns will be identical to B. and C. results, 
without the tedious manual selection of B. and withoutthe time consuming 
C.But, I have to remember again it is the 29/9/2003 !!The two last 
columns preserve the reality of the Range selection. I read the "real" last 
close and the "real" barssince.It is not a magic trick, RestorePriceArrays() 
function did the job.In Indicator Builder see the blue cycle 5 bars ago. The 
real crosses have a black arrow.The red line is the shifted MACD. The red 
arrows occur on the last bar, when the black arrows are on the blue 
cycle.
 
<FONT 
size=2>Plot(MACD(),"",colorBlack,8);event=Cross(0,MACD());PlotShapes(shapeDownArrow*event,colorBlack);shift=5;point=BarIndex()==LastValue(BarIndex())-shift;PlotShapes(shapeCircle*point,colorBlue);Title=Name()+", 
Close="+WriteVal(C);C=Ref(C,-shift);Plot(MACD(),"",4,8);shiftedEvent=Cross(0,MACD());PlotShapes(shapeDownArrow*shiftedEvent,colorRed);
 
E. Some events of the past are still detected. A 
Cross(0,MACD()) six months ago is still visible on an MACD() chart.An 
exploration of B. or C. type will give clear results for a date six months 
ago.Some other events live for some days or weeks and then they disappear 
permanently.The Sept2002 trendlines, for example, are not valid 
anymore.Any B. or C. exploration for a Sept2002 date would give no 
output.The D. alternative could shift everything by one year and allow the 
Sept2002 study.
 
Dimitris Tsokakis






Yahoo! Groups Sponsor


  ADVERTISEMENT<img
src="" width=300 height=250 border=0>  









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Attachment:
shift.gif

Attachment: Description: "Description: GIF image"