Intraday Values on Daily Scan

I am scanning daily OHLC data for Gaps .. I would like to get first 5 minutes bar data for those .. I am not getting it .. Appreciate any help


yDayH = 	TimeFrameGetPrice("H", inDaily, -1);	   		 
yDayL = 	TimeFrameGetPrice("L", inDaily, -1);	 		 
yDayC = 	TimeFrameGetPrice("C", inDaily, -1);
yDayO = 	TimeFrameGetPrice("O", inDaily, -1);


DayH = 	TimeFrameGetPrice("H", inDaily  );	   		 
DayL = 	TimeFrameGetPrice("L", inDaily  );	 		 
DayC = 	TimeFrameGetPrice("C", inDaily );
DayO = 	TimeFrameGetPrice("O", inDaily );
DayRange = DayH - DayL ;
DayOpen2Close =  DayC - DayO ;

Gapupday = DayO >  yDayC ;
Gapdownday = DayO < yDayC ;
GAPValue = DayO-yDayC  ;

Gapday= Gapupday OR Gapdownday ;


TimeFrameSet(in5Minute);
NewDay = Day() != Ref(Day(), -1); 
FBrange=ValueWhen(Day()!=Ref(Day(),-1),H-L); // Todays  First Bar Range 
FBH=ValueWhen(Day()!=Ref(Day(),-1),H); // Todays  First Bar H
FBL=ValueWhen(Day()!=Ref(Day(),-1),L); // Todays  First Bar  L 
TimeFrameRestore();

FBHExpand = TimeFrameExpand(FBH,in5Minute,expandLast);
 







Filter=Gapday;  
AddColumn(yDayH,"yHigh");  
AddColumn(yDayL,"yLOW");  
AddColumn(DayO,"Gapday Open");  
AddColumn(GAPValue,"GAP");  
AddColumn(DayH,"Gapday High " );  
AddColumn(DayL,"Gapday Low " );  
AddColumn(DayC,"Gapday Close " );  
AddColumn(DayRange,"Gapday Range " ); 
AddColumn(DayOpen2Close,"Gapday o2c Range " ); 
AddColumn(FBHExpand,"5mins High " ); 

image

my 5 mins high is coming is day high value .. obviously my code is wrong .. don't know how to get intraday data on daily scan .. appreciate any one help

Looking at the Date/Time column, it appears you are running the Analysis with Periodicity set to Daily under settings.

In Daily Timeframe (Periodicity), you cannot access intraday data.
TimeFrameSet(in5Minute); This isn't going to work.

Thank you Travick. If i use 5 minutes time frame, i am getting same reult every 5 minutes in explorer . How i do to show only one time in the explorer result ?

image


TimeFrameSet(inDaily);
	yDayH= 	 H ;	   		 
	yDayL=  L   ;	 		 
	yDayC= 	 C ;
	yDayO= 	 O  ;
	yDayHe= TimeFrameExpand(yDayH,inDaily,expandLast);
	yDayLe= TimeFrameExpand(yDayL,inDaily,expandLast);
	yDayCe= TimeFrameExpand(yDayC,inDaily,expandLast);
	yDayOe= TimeFrameExpand(yDayO,inDaily,expandLast);

TimeFrameRestore();

//yDayH = TimeFrameGetPrice( "H", inDaily, -1 ) ; // gives previous Day High when working on intraday data
//yDayL=  TimeFrameGetPrice( "L", inDaily, -1 ) ;
//yDayC= 	TimeFrameGetPrice( "C", inDaily, -1 ) ;
//yDayO= 	TimeFrameGetPrice( "O", inDaily, -1 ) ;


 
	
	
	
	

DayH= 	TimeFrameGetPrice("H", inDaily  );	   		 
DayL= 	TimeFrameGetPrice("L", inDaily  );	 		 
DayC= 	TimeFrameGetPrice("C", inDaily );
DayO= 	TimeFrameGetPrice("O", inDaily );

DayRange = DayH - DayL ;
DayOpen2Close =  DayC - DayO ;

Gapupday= 		DayO > yDayCe ;
Gapdownday= 	DayO < yDayCe ;
GAPValue= 		DayO - yDayCe  ;

Gapday= Gapupday OR Gapdownday ;
 

 
TimeFrameSet(in5Minute);
	NewDay = Day() != Ref(Day(), -1); 
	FBrange=ValueWhen(Day()!=Ref(Day(),-1),H-L); // Todays  First Bar Range 
	FBH=ValueWhen(Day()!=Ref(Day(),-1),H); // Todays  First Bar H
	FBL=ValueWhen(Day()!=Ref(Day(),-1),L); // Todays  First Bar  L 
	FBHExpand = TimeFrameExpand(FBH,in5Minute,expandLast);

TimeFrameRestore();

	 
 

  

 




Filter=Gapday;  
AddColumn( yDayHe,"yHigh");  
AddColumn(yDayLe,"yLOW");  
AddColumn(DayO,"Gapday Open");  
AddColumn(GAPValue,"GAP");  
AddColumn(DayH,"Gapday High " );  
AddColumn(DayL,"Gapday Low " );  
AddColumn(DayC,"Gapday Close " );  
AddColumn(DayRange,"Gapday Range " ); 
AddColumn(DayOpen2Close,"Gapday o2c Range " ); 
AddColumn(FBHExpand ,"5mins High " ); 

This is my next take

  1. i did not understood why
    yDayH= H ; is giving me yesterdaty high instead of yDayH= Ref( H ,-1);
  2. How do i get one result of one date when i use explorer instead same 5 mins data for every 5 mins

image

Appreciate anyone time

@amsai
1: 5 minutes = in5Minute not inDaily
2: Read Amibroker help how to use TimeFrameExpand properly
3: Search forum for “NewDay” logic to get what you want.

Ok. Thank you . will do . How can i show only one result if isue 5minutes scan instead of same result over and over again?

You can either use the Filter or Explore using 1 recent bar(s) but it isn't clear what you are trying to do and for what period of data.

Take out some time and explain in detail, also rewrite your AFL so that it is suited for 5m TF,
and clearly mention what settings you are using in the AA window.

Thanks Travick . I am trying to collect all Gapdays date , previous day high , low , today OHLC with first 5 minutes bar high value in explorer . 1 recent bar means i am struck with latest gap day . Would like to see previous days also..

Trying to see daily data values and intraday values together

so which AFL and what settings ? instead of responding quickly, respond in detail.
What Is the periodicity?
If it is 5m, then in your 2nd AFL , why do you have this?
TimeFrameSet(in5Minute);

OK. Thanks for your patience. Let me give a try

TimeFrameSet(inDaily);
	yDayH= 	 H ;	   		 
	yDayL=  L   ;	 		 
	yDayC= 	 C ;
	yDayO= 	 O  ;
	
TimeFrameRestore();


yDayHe= TimeFrameExpand(yDayH,inDaily,expandLast);
yDayLe= TimeFrameExpand(yDayL,inDaily,expandLast);
yDayCe= TimeFrameExpand(yDayC,inDaily,expandLast);
yDayOe= TimeFrameExpand(yDayO,inDaily,expandLast);
	
	
	

DayH= 	TimeFrameGetPrice("H", inDaily  );	   		 
DayL= 	TimeFrameGetPrice("L", inDaily  );	 		 
DayC= 	TimeFrameGetPrice("C", inDaily );
DayO= 	TimeFrameGetPrice("O", inDaily );

DayRange = DayH - DayL ;
DayOpen2Close =  DayC - DayO ;

Gapupday= 		DayO > yDayCe ;
Gapdownday= 	DayO < yDayCe ;
GAPValue= 		DayO - yDayCe  ;

Gapday= Gapupday OR Gapdownday ;
 

 
dn = DateNum();
newDay = dn != Ref( dn, -1 );
FirstBarOpen = ValueWhen( newday, Open );
FirstBarHigh = ValueWhen( newday, High);
FirstBarLow = ValueWhen( newday, Low );
FirstBarClose = ValueWhen( newday, Close);
FirstBarVolume = ValueWhen( newday, Volume);

YesterdayFBO = ValueWhen( newday, Open, 2 );
YesterdayFBH = ValueWhen( newday, High, 2);
YesterdayFBL = ValueWhen( newday, Low, 2 );
YesterdayFBC = ValueWhen( newday, Close, 2);
YesterdayFBV = ValueWhen( newday, Volume, 2);
	

 


Filter=Gapday;  
AddColumn( yDayHe,"yHigh");  
AddColumn(yDayLe,"yLOW");  
AddColumn(DayO,"Gapday Open");  
AddColumn(GAPValue,"GAP");  
AddColumn(DayH,"Gapday High " );  
AddColumn(DayL,"Gapday Low " );  
AddColumn(DayC,"Gapday Close " );  
AddColumn(DayRange,"Gapday Range " ); 
AddColumn(DayOpen2Close,"Gapday o2c Range " ); 
AddColumn(FirstBarHigh ,"5mins High " ); 
 

When i run above AFL in explorer with "Daily" in settings with an objective to collect I am trying to collect all Gapdays date , previous day high , low , today OHLC with first 5 minutes bar high value in explorer , i am getting 5 minutes high as Days high.

image

I would like to get in above fomat . To get the 5 minutes ,If change change setting to 5 minutes i am getting correct data but multiple times for every 5 minutes

image

so how do i get correct data like in first image in one row for each day . Thanks again for your patience

tn = TimeNum();
firstBar = tn == 91500;
Filter = Gapday AND firstBar;

You can add a Filter for only the first bar of the day, from your image it appears to be 9:15am

This applies to the code run in 5m Periodicity.

1 Like

Ohh God , that did the trick .

Thanks a lot travick . I still don't understand why folowing code fetching yesterday values instead of today

TimeFrameSet(inDaily);
	yDayH= 	 H ;	   		 
	yDayL=  L   ;	 		 
	yDayC= 	 C ;
	yDayO= 	 O  ;
	
TimeFrameRestore();

If you have time otherwise fine . Again Thanks a lot

I don't think that is where the problem is.

Its more likely to be here
TimeFrameExpand(yDayH,inDaily,expandLast);

You can try using ExpandFirst or atleast study how the expanded array will behave under the various parameters.

and just for the record, something more generic instead of hard coding could be

tn = TimeNum();
nd = Day() != Ref(Day(), -1);
fb = ValueWhen( nd, tn, 1);
firstBar = tn == LastValue( fb );

Sure . Thank you vey much . Appreciate you time and patience

Reallly, why adding more code (adding more complication) just for getting first bar of day flag?
All variables are there already.

@amsai, in your code you already have first bar of day flag -> newday variable.

dn = DateNum();
newDay = dn != Ref( dn, -1 );// this is first bar of day flag already

So all you have to do is adding that one to filter variable

Filter = newday AND GapDay;

And if you want to get last day's one only then simply add this one instead (again using already available variables).

Filter = newday AND GapDay AND dn == LastValue(dn);

No need for new variables and new code lines.


BTW, instaed of this one

TimeFrameSet(inDaily);
	yDayH= 	 H ;	   		 
	yDayL=  L   ;	 		 
	yDayC= 	 C ;
	yDayO= 	 O  ;	
TimeFrameRestore();

yDayHe= TimeFrameExpand(yDayH,inDaily,expandLast);
yDayLe= TimeFrameExpand(yDayL,inDaily,expandLast);
yDayCe= TimeFrameExpand(yDayC,inDaily,expandLast);
yDayOe= TimeFrameExpand(yDayO,inDaily,expandLast);
	

DayH= 	TimeFrameGetPrice("H", inDaily  );	   		 
DayL= 	TimeFrameGetPrice("L", inDaily  );	 		 
DayC= 	TimeFrameGetPrice("C", inDaily );
DayO= 	TimeFrameGetPrice("O", inDaily );

You can do this one

yDayHe = TimeFrameGetPrice("H", inDaily, -1 );	
yDayLe = TimeFrameGetPrice("L", inDaily, -1 );	 	
yDayCe = TimeFrameGetPrice("C", inDaily, -1 );	 	
yDayOe = TimeFrameGetPrice("O", inDaily, -1 );	 	
	
DayH = TimeFrameGetPrice("H", inDaily );	   		 
DayL = TimeFrameGetPrice("L", inDaily );	 		 
DayC = TimeFrameGetPrice("C", inDaily );
DayO = TimeFrameGetPrice("O", inDaily );
2 Likes

This is in the context of discussion on coding approach, it was not intended to be directly pasted to his code.
His main learning was to set the correct periodicity and Filter the first 5m bar that is in post #10.

Thanks @fxshrat . You always make it coding as simple as possible . @travick was trying to help me and learn by myself and inbetween i confused him . Thanks @travick

I ran in to little trouble. Trying to get price at certain time on gap day but picking up value from exact time from yesterday .. Not sure what i am doing wrong now


yDayHe = TimeFrameGetPrice("H", inDaily, -1 );	
yDayLe = TimeFrameGetPrice("L", inDaily, -1 );	 	
yDayCe = TimeFrameGetPrice("C", inDaily, -1 );	 	
yDayOe = TimeFrameGetPrice("O", inDaily, -1 );	
	
	
	

DayH= 	TimeFrameGetPrice("H", inDaily  );	   		 
DayL= 	TimeFrameGetPrice("L", inDaily  );	 		 
DayC= 	TimeFrameGetPrice("C", inDaily );
DayO= 	TimeFrameGetPrice("O", inDaily );

DayRange = DayH - DayL ;
DayOpen2Close =  DayC - DayO ;

Gapupday= 		DayO > yDayCe ;
Gapdownday= 	DayO < yDayCe ;
GAPValue= 		DayO - yDayCe  ;

Gapday= Gapupday OR Gapdownday ;
 

 
dn = DateNum();
newDay = dn != Ref( dn, -1 );
FirstBarOpen = ValueWhen( newday, Open );
FirstBarHigh = ValueWhen( newday, High);
FirstBarLow = ValueWhen( newday, Low );
FirstBarClose = ValueWhen( newday, Close);
FirstBarVolume = ValueWhen( newday, Volume);

YesterdayFBO = ValueWhen( newday, Open, 2 );
YesterdayFBH = ValueWhen( newday, High, 2);
YesterdayFBL = ValueWhen( newday, Low, 2 );
YesterdayFBC = ValueWhen( newday, Close, 2);
YesterdayFBV = ValueWhen( newday, Volume, 2);

tn = TimeNum();

Priceat245 = ValueWhen ( tn == 144500, C)  ;
 
	
 //Filter = newday AND GapDay AND dn == LastValue(dn);  
 Filter = Gapday AND newDay;

//Filter=Gapday;  
AddColumn( yDayHe,"yHigh");  
AddColumn(yDayLe,"yLOW");  
AddColumn(DayO,"Gapday Open");  
AddColumn(GAPValue,"GAP");  
AddColumn(DayH,"Gapday High " );  
AddColumn(DayL,"Gapday Low " );  
AddColumn(DayC,"Gapday Close " );  
AddColumn(DayRange,"Gapday Range " ); 
AddColumn(DayOpen2Close,"Gapday o2c Range " ); 
AddColumn(FirstBarHigh ,"5mins High " ); 
AddColumn(Priceat245,"  2:45 PM Price " ); 

image

i also tried

Priceat245 = ValueWhen ( tn == 144500, C)  and newDay ;

but not helping

appreciate your time and guidance

@travick,

It does not matter in which context because my remark is still valid.

Simplicity is proper coding approach but not overcomplication.

Your 'nd' variable already is marking first bar of day.

So all after is things done twice leading to redundant code.

One line

nd = firstBar = Day() != Ref(Day(), -1);

Filter = 
firstBar ;

vs. four lines.

tn = TimeNum();
nd = Day() != Ref(Day(), -1);
fb = ValueWhen( nd, tn, 1);
firstBar = tn == LastValue( fb );

Filter = firstBar;

Obviously one line 'nd' or 'newday' (as in his code) is all that is needed.

@fxshrat or @travick I am still getting yesterday 2:45 PM values when i do the explorer instead of GAP day 2:45 pm value
. How do i get Gap day 2:45 value ? I am doing something wrong . Appreciate you guys can correct me

Can you post the latest version of your code along with analysis settings that you have used.