Pete,

below an example how to do it,

rgds, Ed


starttime = 093000;
endtime = 160000;

timecond = TimeNum() >= starttime AND TimeNum() <= endtime;

firstBarOfDay = TimeNum() >= starttime ;firstBarOfDay = firstBarOfDay - 
Ref(firstBarOfDay,-1);
lastBarOfDay = TimeNum() >= endtime;lastBarOfDay = lastBarOfDay - 
Ref(lastBarOfDay,-1);

myHigh = ValueWhen( timecond, HighestSince( firstBarOfDay, High) ); 
myLow = ValueWhen( timecond, LowestSince( firstBarOfDay, Low) ); 
myClose = ValueWhen(lastBarOfDay,C);

DH = TimeFrameCompress(myHigh, inDaily, compressLast); 
DL = TimeFrameCompress(myLow, inDaily, compressLast); 
DC = TimeFrameCompress(myClose, inDaily, compressLast); 

DH = Ref(DH,-1);
DL = Ref(DL,-1);
DC = Ref(DC,-1);

YHigh = TimeFrameExpand( DH, inDaily, expandFirst ); 
YLow = TimeFrameExpand( DL, inDaily, expandFirst ); 
YClose = TimeFrameExpand( DC, inDaily, expandFirst ); 




  ----- Original Message ----- 
  From: Pete 
  To: [email protected] 
  Sent: Sunday, July 19, 2009 5:44 AM
  Subject: [amibroker] Intra-Day Database Setup


    There is a topic in the help files titled "Database Settings". There is a 
section where it explains how to use the trading hours to define precisely how 
time-compression works. I would like to know how I can set the Day/Night 
session start and end times such that the time compression will only take the 
O,H,L,C from between the market open at 9:30 am eastern to the market close at 
4:00 pm eastern. 

  I have spent hours trying to adjust these values and then wright a simple 
code which accurately calculates daily moving averages using time compression 
in a intra-day time frame. No matter what I try I am always left with assigning 
the values of O,H,L,C using the TimeNum() >= 093000 and TimeNum() <= 160000 
statements.

  The goal is the able to use a simple code:
  Timeframeset(indaily);
  DlyH = H;
  DlyL = L;
  DlyMA = MA(H-L,10);
  Timeframerestore(indaily);
  Plot(Timeframeexpand(DlyMA,indaily), "Dly H-L", colorRed, StyleLine);

  Thanks.

  Pete :-)



  

Reply via email to