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

Re: [amibroker] Retrieving yesterday's daily O/H/L/C during RTH in an intraday database?



PureBytes Links

Trading Reference Links

Hi,

I use this code to catch the HHV and LLV of the today's first hour.

Maybe this can give you ideas to adapt to your need.

Best regards

// High and Low of the first 60 minutes

starttime = 080000;

endtime = 084500;// write 084500 to catch the close of 090000 in 15' TU

tn = TimeNum();

timecond = tn >= starttime AND tn <= endtime;

firstBarOfDay = timecond ;

firstBarOfDay = firstBarOfDay - Ref( firstBarOfDay, -1 );

xHigh = ValueWhen( timecond, HighestSince( firstBarOfDay, High ) );

xLow = ValueWhen( timecond, LowestSince( firstBarOfDay, Low ) );

DH = TimeFrameCompress( xHigh, inDaily, compressLast );

DL = TimeFrameCompress( xLow, inDaily, compressLast );

DH = TimeFrameExpand( DH, inDaily, expandFirst );

DL = TimeFrameExpand( DL, inDaily, expandFirst );

SetBarsRequired( -2, -2 );

SetChartOptions( 0, chartShowDates );

Plot( C, "C", colorWhite, 64 );

//Plot( IIf( tn > endtime , DH, Null ), "\nDH", colorRed, styleThick + 
styleDashed + styleThick+styleNoLabel);
PlotShapes( IIf( tn > endtime , shapeHollowSmallCircle, shapeNone) 
,colorBlue, 0, DH, 0  );
//Plot( IIf( tn > endtime , DL, Null ), "DL", colorGreen, styleThick + 
styleDashed + styleThick+styleNoLabel);
PlotShapes( IIf( tn > endtime , shapeHollowSmallCircle, shapeNone) 
,colorBlue, 0, DL, 0  );
//Plot( timecond, "", colorLightGrey, styleArea | styleOwnScale, 0, 1 );

//2.61% support AND resistance

res261 = DL + (DH - DL)  * 2.618;

sup261 = DH - (DH - DL)* 2.618;

Plot( res261 , "\nR261", colorGold, 8 );//"261,8% Resistance."

Plot( sup261 , "S261", colorGold, 8 );//"261,8% Support."

GraphXSpace = 10;

rmicalet a écrit :
>  
> 
> Does anyone happen to know how to do the following:
> 
> I have a one-minute database that shows 24 hours of data. To compute
> pivots, I'd like to retrieve yesterday's O/H/L/C, but only from the
> regular trading session (9:30 am to 4:00 pm, New York time). If I simply
> take the O/H/L/C of the previous day's data I'll get the values
> corresponding to the entire 24 hour range of prices. Ideally, I'd like
> to isolate the one-minute bars from yesterday at 9:30 am to yesterday at
> 4:00 pm and then find the max, min, and last price.
> 
> I imagine the solution entails something like:
> 
> startBar = ValueWhen( timeNum() == 093000 and ???, barIndex());
> endBar = ValueWhen( timeNum() == 160000 and ???, barIndex());
> yesterday_high = HHV(barIndex() >= startBar AND barIndex() <= endBar,
> H);
> yesterday_low = LLV( barIndex() >= startBar AND barIndex() <= endBar,
> L);
> yesterday_close = ValueWhen(barIndex() == endBar, C);
> 
> In the expressions for "startBar" and "endBar", I'm not sure how to
> construct the condition that the day in question is yesterday when
> dealing with a one-minute database. I tried:
> 
> timeFrameSet( inDaily);
> yesterday = Ref(Day(),-1);
> timeFrameRestore();
> 
> startBar = ValueWhen ( timeNum() == 093000 AND Day() == yesterday,
> BarIndex());
> endBar = ValueWhen ( timeNum() == 160000 AND Day() == yesterday,
> BarIndex());
> 
> But that doesn't seem to work as no indicators show up when I plot them
> out.
> 
> I suspect I'm making this a lot harder than it is. Would be grateful for
> any insight.
> 
> Regards,
> Ray Micaletti
> 
> 



------------------------------------

**** 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/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/