hi,
here is 1 way of doing it, regards, Ed
// current
price
current_price = C;
// price X days
back at same time X = 1; // 1 day
back
// current
time ct = LastValue(TimeNum());
// bar at current time bact = TimeNum() >= ct; bact = bact -
Ref(bact,-1);
// price at current
time pact = ValueWhen(bact == 1,C);
// compress to daily in order to make the shift
X
DP = TimeFrameCompress(pact, inDaily, compressLast);
// perform the shift X days back DP = Ref(DP,-1 * X);
// expand back to
current time interval from daily cti = TimeFrameExpand( DP, inDaily, expandFirst );
GraphXSpace = 5; SetChartOptions(0,
chartShowDates); Plot(C,"\nLast",colorWhite,64); Plot(cti,"\ncti",colorWhite,1); PlotShapes(IIf(bact == 1,shapeCircle,shapeNone),colorWhite,0,C,0);
""; "Current price at time " + WriteVal(ct) + " " + WriteVal(C); "Price at time
" + WriteVal(ct) + " " +
NumToStr(X) + " days back: " + WriteVal(LastValue(cti));
----- Original Message -----
Sent: Friday, January 08, 2010 10:53
PM
Subject: [amibroker] Price at Specified
Time
Hi-
I am using intraday data and would like to be able to get the price from
the exact same time of day as the current bar but from x days ago. I
tried to accomplish this with ValueWhen() but I can't think of a way to set
the current bar time constant. Can anyone help?
x=2;
CurrBarTime = TimeNum();
ValAtTime = ValueWhen(TimeNum() == CurrBarTime,C,X);
...obviously the CurrBarTime just continues to roll back along with the
ValueWhen function.
Also, if I can get this to work, I am likely to come across a scenario
where there is no bar available for exactly same time on previous days.
In that instance I'd like to take the next closest bar...would also appreciate
any thoughts on how to do that..
Thank you.
__._,_.___
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
__,_._,___
|