Intraday/Daily Compession

Hello,

I have tried time and again to figure out how to get my daily/intraday time compression to work the way I want it to. I want to access all the data that includes premarket and afterhours without including it in the compression for the daily time frame. I have tried playing with the settings in every which way and haven't been able to get it to work.

I have posted about this previously with no response, but I desperately want to know what it is I am doing incorrectly or if I need to synthetically develop daily bars in my code with my intraday data so I can reference the information I am trying to retrieve.

Below is a screenshot of my intraday settings window and the code I have been messing with that I initially had chatGPT write. I apologize for the messy code as I have been going back and forth trying to reference the daily data a different way.

Any help is appreciated

TimeFrameSet( inDaily );

// Daily gap condition
DailyGapPct = ((Open-Ref(Close,-1))/Ref(Close,-1)) * 100;
Cond_DailyGap = DailyGapPct >= 3;

// 20-day average volume
DailyAvgVol = Ref(MA( Volume, 20 ),1);
Cond_DailyAvgVol = DailyAvgVol >= 2000000;

// Prior day ATR
DailyATR = Ref(ATR(14),-1);
Cond_DailyATR = DailyATR >= 1;

TimeFrameRestore();

// ---------------------------------------------------------------
// 2. EXPAND DAILY VALUES INTO INTRADAY
// ---------------------------------------------------------------
GapOK      = TimeFrameExpand( Cond_DailyGap,     inDaily, expandFirst );
AvgVolOK   = TimeFrameExpand( Cond_DailyAvgVol,  inDaily, expandFirst );
ATROK      = TimeFrameExpand( Cond_DailyATR,     inDaily, expandFirst );

// ---------------------------------------------------------------
// 3. PREMARKET VOLUME (4:00–9:29am EST) -- Ignore due to filtering
// ---------------------------------------------------------------

DailyATR_i = TimeFrameExpand( DailyATR, inDaily, expandFirst );

tn = TimeNum();

NewDay = Day()!=Ref(Day(),-1);

premarket_start_time = 040000;
premarket_end_time = 093000;

regular_session_start_time = 093000;
regular_session_end_time = 160000;

after_hours_start_time = 160000;
after_hours_end_time = 200000;


PM_StartTime = 40000;
PM_EndTime = 92900;

Open_Time = 93000;
AM_Rule = 100000;
Midday_Time = 120000;
EOD_Time = 160000;

// these conditions are true when TimeNum of the bar equals startime/endtime
PM_StartBar = Cross(tn,PM_StartTime);													// Premarket Start Bar Condition
PM_EndBar = tn == PM_Endtime;															// Premarket End Bar Condition

M_StartBar = Cross(tn,PM_EndTime);														// Morning Start Bar Condition
AM_RuleBar = tn<=AM_Rule;																// 10 AM Rule Bar Condition
MD_EndBar = tn <= Midday_Time;															// Morning End Bar Condition

EOD_Bar = tn == EOD_Time;																// EOD Bar Condition
EOD_RuleBar = tn <= EOD_Time;

PM_Vol = ValueWhen( PM_EndBar, SumSince( NewDay , V ) );								// Premarket Volume

Cond_PremarketVol = PM_Vol > 200000;

// ---------------------------------------------------------------
// Daily Gap % Calculation
// ---------------------------------------------------------------

DayO_i = ValueWhen(tn==Open_Time,Open); // Todays Open

yDayC_i = Ref(ValueWhen(tn==EOD_Time,Close),-1); // Yesterdays Close

GapPct_i = ((DayO_i-yDayC_i)/yDayC_i)*100; // Gap%?

// ---------------------------------------------------------------
// ATR Calculation
// ---------------------------------------------------------------

// ---------------------------
// Calculated Highs
// ---------------------------

H1 = Ref(ValueWhen(tn==EOD_Time,HHV(High,Ref(ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)),-2))),-2); 
H2 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-2); 
H3 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-3); 
H4 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-4); 
H5 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-5); 
H6 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-6); 
H7 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-7); 
H8 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-8); 
H9 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-9); 
H10 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-10); 
H11 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-11); 
H12 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-12); 
H13 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-13); 
H14 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-14); 
H15 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-15); 

// ---------------------------
// Calculated Lows
//-----------------------------

L1 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L2 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L3 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L4 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L5 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L6 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L7 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L8 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L9 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L10 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L11 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L12 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L13 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L14 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L15 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);

// ---------------------------
// Calculated Close
//-----------------------------

yC1 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC2 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC3 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC4 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC5 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC6 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC7 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC8 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC9 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC10 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC11 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC12 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC13 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC14 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC15 = Ref(ValueWhen(tn==EOD_Time,Close),-1);


// ---------------------------
// Calculated TR
//-----------------------------

HL = (H15-L15) + (H2-L2) + (H3-L3) + (H4-L4) + (H5-L5) + (H6-L6) + (H7-L7)
	+ (H8-L8) + (H9-L9) + (H10-L10) + (H11-L11)+ (H12-L12) + (H13-L13) + (H14-L14);
	
HyC = (H1-yC1) + (H2-yC2) + (H3-yC3) + (H4-yC4) + (H5-yC5) + (H6-yC6) + (H7-yC7)
	+ (H8-yC8) + (H9-yC9) + (H10-yC10) + (H11-yC11)+ (H12-yC12) + (H13-yC13) + (H14-yC14);
	
LyC = (L1-yC1) + (L2-yC2) + (L3-yC3) + (L4-yC4) + (L5-yC5) + (L6-yC6) + (L7-yC7)
	+ (L8-yC8) + (L9-yC9) + (L10-yC10) + (L11-yC11)+ (L12-yC12) + (L13-yC13) + (L14-yC14);
	
ATR_Calc = (((HL/14)*13)+(H1-L1))/14;

// ---------------------------------------------------------------
// 20D Avg Volume Calculation
// ---------------------------------------------------------------

// ---------------------------
// Calculate EOD Bar and Sum Vol
//-----------------------------


EODBar = HHV(tn,tn>=195000);
VolT = SumSince( NewDay , V );

// ---------------------------
// Calculate Vol for 20 Days
//-----------------------------

yDV1  = ValueWhen(tn==EODBar,VolT);
yDV2  = Ref(ValueWhen(tn==EODBar,VolT),-1);
yDV3  = Ref(ValueWhen(tn==EODBar,VolT),-2);
yDV4  = Ref(ValueWhen(tn==EODBar,VolT),-3);
yDV5  = Ref(ValueWhen(tn==EODBar,VolT),-4);
yDV6  = Ref(ValueWhen(tn==EODBar,VolT),-5);
yDV7  = Ref(ValueWhen(tn==EODBar,VolT),-6);
yDV8  = Ref(ValueWhen(tn==EODBar,VolT),-7);
yDV9  = Ref(ValueWhen(tn==EODBar,VolT),-8);
yDV10 = Ref(ValueWhen(tn==EODBar,VolT),-9);
yDV11  = Ref(ValueWhen(tn==EODBar,VolT),-10);
yDV12  = Ref(ValueWhen(tn==EODBar,VolT),-11);
yDV13  = Ref(ValueWhen(tn==EODBar,VolT),-12);
yDV14  = Ref(ValueWhen(tn==EODBar,VolT),-13);
yDV15 = Ref(ValueWhen(tn==EODBar,VolT),-14);
yDV16 = Ref(ValueWhen(tn==EODBar,VolT),-15);
yDV17 = Ref(ValueWhen(tn==EODBar,VolT),-16);
yDV18 = Ref(ValueWhen(tn==EODBar,VolT),-17);
yDV19 = Ref(ValueWhen(tn==EODBar,VolT),-18);
yDV20 = Ref(ValueWhen(tn==EODBar,VolT),-19);


AvgVol20D = (yDV1 + yDV2 + yDV3 + yDV4 + yDV5 + yDV6 + yDV7 + yDV8 + yDV9 + yDV10 
	+ yDV11 + yDV12 + yDV13 + yDV14 + yDV15 + yDV16 + yDV17 + yDV18 + yDV19 + yDV20)/20;

// ---------------------------------------------------------------
// 4. FIRST 30 MINUTES LOGIC (9:30–10:00am)
// ---------------------------------------------------------------
SessionOpen = 093000;
Session10 = 094000;
Session30   = 100000;
Session11am = 110000;

IsFirst30 = tn >= SessionOpen AND tn <= Session30;



// High of first 30 minutes
First30High = HighestSince( tn == SessionOpen, High );

// Condition: First 30-min high >= Open + 0.5 ATR
Cond_First30_ATR = First30High >= ( Open + 0.5 * DailyATR_i );

// Detect the bar where the first-30-min high is set
HighHit = High == First30High AND IsFirst30;

BarsSinceHigh = BarsSince(HighHit);

// Track lowest low AFTER the high is set
LowAfterHigh = LLV(Low,BarsSinceHigh);

//VWAP Calc
VWAP = SumSince( NewDay, Avg * Volume) / SumSince( NewDay, Volume );


// Condition: lowest low after high < VWAP
Cond_LowBelowVWAP = Cross(VWAP, LowAfterHigh) AND tn >= Session10 AND tn <= Session11am;

// Bars Since VWAP Touch

High_Entry_Cond = BarsSince(Cond_LowBelowVWAP) == 11; //Minimum 10 bars after VWAP is touched

Entry_High_Find = HighestSince(Cond_LowBelowVWAP,High); //Find high value after crossing vwap

Entry_High = ValueWhen(High_Entry_Cond,Entry_High_Find); //High value for entry price

Entry_Signal = Cross(High,Entry_High); //Enter when consolidation high is broken

Risk_Low_Find = LowestSince(Cond_LowBelowVWAP,High); //Find Risk

Risk_Low = ValueWhen(High_Entry_Cond,Risk_Low_Find); //Risk Value

Sell_Signal = Cross(Risk_Low,Low); //Sell when consolidation low is broken

EC2 = tn >= Session10 AND tn <= Session11am;

EC3 = ValueWhen(Cond_LowBelowVWAP,DateTime()) < ValueWhen(Entry_Signal, DateTime()); //Only enter after vwap is crossed first

// 6. FINAL TRADE CONDITION
// ---------------------------------------------------------------


Filter = 1;//Entry_Signal AND EC2 AND Cond_PremarketVol AND GapPct_i>=3;

AddColumn( GapPct_i,        "Gap %", 1.2 );
//AddColumn(Avg20Vol,        "20D Avg Vol", 1.2);
AddColumn( H1 ,"Prior ATR", 1.2 );
AddColumn( PM_Vol,       "Premarket Vol", 1.2 );
AddColumn( First30High,        "First 30 High", 1.2 );
AddColumn( LowAfterHigh,       "Low After High", 1.2 );
AddColumn( vwap,               "VWAP", 1.2 );
AddColumn( Entry_High,          "High Entry", 1.2 );
AddColumn( Entry_Signal,          "High Signal", 1.2 );
//AddColumn( TradeSignal,        "Signal", 1.0 );
//AddColumn( BarsSinceHigh,        "BarsSince high", 1.0 );

I believe that the subject is covered here:

and also some here: AmiBroker Knowledge Base » Time compression of data retrieved from another symbol

Note that these settings affect "DAILY" interval selected from UI, not anything that you do inside your AFL code.

I have reviewed that link quite a bit and maybe I am just not understanding or not doing something right.

To be clear with my goal/intentions. I would like to compress to a daily bar from intraday data without losing access to premarket data, but still calculate the data required correctly.

Here is what I get when with my current filtering:


**

**
With the settings shown below, I get what I am looking for with the chart compression, but it restricts access to the premarket data


When I show day/night filtering, the calculation for the daily values is not correct. I did have mixed data on for this so the chart appears as I expect, but the calculation from the code does not give me similar values.

It is also worth noting that I got the daily data from a different vendor as my intraday so I expect it not to be exact, but it is a much larger difference than I anticipated.



Below is a slightly updated but still messy code. All I really added was a variable to view the ATR

I am a bit lost on what I am not doing correctly or not understanding to get my desired outcome. All help is appreciated. Thank you

TimeFrameSet( inDaily );

// Daily gap condition
DailyGapPct = ((Open-Ref(Close,-1))/Ref(Close,-1)) * 100;
Cond_DailyGap = DailyGapPct >= 3;

// 20-day average volume
DailyAvgVol = Ref(MA( Volume, 20 ),1);
Cond_DailyAvgVol = DailyAvgVol >= 2000000;

// Prior day ATR
DailyATR = Ref(ATR(14),-1);
Cond_DailyATR = DailyATR >= 1;

TimeFrameRestore();

// ---------------------------------------------------------------
// 2. EXPAND DAILY VALUES INTO INTRADAY
// ---------------------------------------------------------------
GapOK      = TimeFrameExpand( Cond_DailyGap,     inDaily, expandFirst );
AvgVolOK   = TimeFrameExpand( Cond_DailyAvgVol,  inDaily, expandFirst );
ATROK      = TimeFrameExpand( Cond_DailyATR,     inDaily, expandFirst );

DailyATR_i = TimeFrameExpand(DailyATR, inDaily);
// ---------------------------------------------------------------
// 3. PREMARKET VOLUME (4:00–9:29am EST) -- Ignore due to filtering
// ---------------------------------------------------------------

DailyATR_i = TimeFrameExpand( DailyATR, inDaily, expandFirst );

tn = TimeNum();

NewDay = Day()!=Ref(Day(),-1);

premarket_start_time = 040000;
premarket_end_time = 093000;

regular_session_start_time = 093000;
regular_session_end_time = 160000;

after_hours_start_time = 160000;
after_hours_end_time = 200000;


PM_StartTime = 40000;
PM_EndTime = 92900;

Open_Time = 93000;
AM_Rule = 100000;
Midday_Time = 120000;
EOD_Time = 160000;

// these conditions are true when TimeNum of the bar equals startime/endtime
PM_StartBar = Cross(tn,PM_StartTime);													// Premarket Start Bar Condition
PM_EndBar = tn == PM_Endtime;															// Premarket End Bar Condition

M_StartBar = Cross(tn,PM_EndTime);														// Morning Start Bar Condition
AM_RuleBar = tn<=AM_Rule;																// 10 AM Rule Bar Condition
MD_EndBar = tn <= Midday_Time;															// Morning End Bar Condition

EOD_Bar = tn == EOD_Time;																// EOD Bar Condition
EOD_RuleBar = tn <= EOD_Time;

PM_Vol = ValueWhen( PM_EndBar, SumSince( NewDay , V ) );								// Premarket Volume

Cond_PremarketVol = PM_Vol > 200000;

// ---------------------------------------------------------------
// Daily Gap % Calculation
// ---------------------------------------------------------------

DayO_i = ValueWhen(tn==Open_Time,Open); // Todays Open

yDayC_i = Ref(ValueWhen(tn==EOD_Time,Close),-1); // Yesterdays Close

GapPct_i = ((DayO_i-yDayC_i)/yDayC_i)*100; // Gap%?

// ---------------------------------------------------------------
// ATR Calculation
// ---------------------------------------------------------------

// ---------------------------
// Calculated Highs
// ---------------------------

H1 = Ref(ValueWhen(tn==EOD_Time,HHV(High,Ref(ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)),-2))),-2); 
H2 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-2); 
H3 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-3); 
H4 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-4); 
H5 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-5); 
H6 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-6); 
H7 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-7); 
H8 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-8); 
H9 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-9); 
H10 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-10); 
H11 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-11); 
H12 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-12); 
H13 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-13); 
H14 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-14); 
H15 = Ref(ValueWhen(tn==EOD_Time,HHV(High,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-15); 

// ---------------------------
// Calculated Lows
//-----------------------------

L1 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L2 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L3 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L4 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L5 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L6 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L7 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L8 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L9 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L10 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L11 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L12 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L13 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L14 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);
L15 = Ref(ValueWhen(tn==EOD_Time,LLV(Low,ValueWhen(tn==EOD_Time,BarsSince(tn==Open_Time)))),-1);

// ---------------------------
// Calculated Close
//-----------------------------

yC1 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC2 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC3 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC4 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC5 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC6 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC7 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC8 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC9 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC10 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC11 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC12 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC13 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC14 = Ref(ValueWhen(tn==EOD_Time,Close),-1);
yC15 = Ref(ValueWhen(tn==EOD_Time,Close),-1);


// ---------------------------
// Calculated TR
//-----------------------------

HL = (H15-L15) + (H2-L2) + (H3-L3) + (H4-L4) + (H5-L5) + (H6-L6) + (H7-L7)
	+ (H8-L8) + (H9-L9) + (H10-L10) + (H11-L11)+ (H12-L12) + (H13-L13) + (H14-L14);
	
HyC = (H1-yC1) + (H2-yC2) + (H3-yC3) + (H4-yC4) + (H5-yC5) + (H6-yC6) + (H7-yC7)
	+ (H8-yC8) + (H9-yC9) + (H10-yC10) + (H11-yC11)+ (H12-yC12) + (H13-yC13) + (H14-yC14);
	
LyC = (L1-yC1) + (L2-yC2) + (L3-yC3) + (L4-yC4) + (L5-yC5) + (L6-yC6) + (L7-yC7)
	+ (L8-yC8) + (L9-yC9) + (L10-yC10) + (L11-yC11)+ (L12-yC12) + (L13-yC13) + (L14-yC14);
	
ATR_Calc = (((HL/14)*13)+(H1-L1))/14;

// ---------------------------------------------------------------
// 20D Avg Volume Calculation
// ---------------------------------------------------------------

// ---------------------------
// Calculate EOD Bar and Sum Vol
//-----------------------------


EODBar = HHV(tn,tn>=195000);
VolT = SumSince( NewDay , V );

// ---------------------------
// Calculate Vol for 20 Days
//-----------------------------

yDV1  = ValueWhen(tn==EODBar,VolT);
yDV2  = Ref(ValueWhen(tn==EODBar,VolT),-1);
yDV3  = Ref(ValueWhen(tn==EODBar,VolT),-2);
yDV4  = Ref(ValueWhen(tn==EODBar,VolT),-3);
yDV5  = Ref(ValueWhen(tn==EODBar,VolT),-4);
yDV6  = Ref(ValueWhen(tn==EODBar,VolT),-5);
yDV7  = Ref(ValueWhen(tn==EODBar,VolT),-6);
yDV8  = Ref(ValueWhen(tn==EODBar,VolT),-7);
yDV9  = Ref(ValueWhen(tn==EODBar,VolT),-8);
yDV10 = Ref(ValueWhen(tn==EODBar,VolT),-9);
yDV11  = Ref(ValueWhen(tn==EODBar,VolT),-10);
yDV12  = Ref(ValueWhen(tn==EODBar,VolT),-11);
yDV13  = Ref(ValueWhen(tn==EODBar,VolT),-12);
yDV14  = Ref(ValueWhen(tn==EODBar,VolT),-13);
yDV15 = Ref(ValueWhen(tn==EODBar,VolT),-14);
yDV16 = Ref(ValueWhen(tn==EODBar,VolT),-15);
yDV17 = Ref(ValueWhen(tn==EODBar,VolT),-16);
yDV18 = Ref(ValueWhen(tn==EODBar,VolT),-17);
yDV19 = Ref(ValueWhen(tn==EODBar,VolT),-18);
yDV20 = Ref(ValueWhen(tn==EODBar,VolT),-19);


AvgVol20D = (yDV1 + yDV2 + yDV3 + yDV4 + yDV5 + yDV6 + yDV7 + yDV8 + yDV9 + yDV10 
	+ yDV11 + yDV12 + yDV13 + yDV14 + yDV15 + yDV16 + yDV17 + yDV18 + yDV19 + yDV20)/20;

// ---------------------------------------------------------------
// 4. FIRST 30 MINUTES LOGIC (9:30–10:00am)
// ---------------------------------------------------------------
SessionOpen = 093000;
Session10 = 094000;
Session30   = 100000;
Session11am = 110000;

IsFirst30 = tn >= SessionOpen AND tn <= Session30;



// High of first 30 minutes
First30High = HighestSince( tn == SessionOpen, High );

// Condition: First 30-min high >= Open + 0.5 ATR
Cond_First30_ATR = First30High >= ( Open + 0.5 * DailyATR_i );

// Detect the bar where the first-30-min high is set
HighHit = High == First30High AND IsFirst30;

BarsSinceHigh = BarsSince(HighHit);

// Track lowest low AFTER the high is set
LowAfterHigh = LLV(Low,BarsSinceHigh);

//VWAP Calc
VWAP = SumSince( NewDay, Avg * Volume) / SumSince( NewDay, Volume );


// Condition: lowest low after high < VWAP
Cond_LowBelowVWAP = Cross(VWAP, LowAfterHigh) AND tn >= Session10 AND tn <= Session11am;

// Bars Since VWAP Touch

High_Entry_Cond = BarsSince(Cond_LowBelowVWAP) == 11; //Minimum 10 bars after VWAP is touched

Entry_High_Find = HighestSince(Cond_LowBelowVWAP,High); //Find high value after crossing vwap

Entry_High = ValueWhen(High_Entry_Cond,Entry_High_Find); //High value for entry price

Entry_Signal = Cross(High,Entry_High); //Enter when consolidation high is broken

Risk_Low_Find = LowestSince(Cond_LowBelowVWAP,High); //Find Risk

Risk_Low = ValueWhen(High_Entry_Cond,Risk_Low_Find); //Risk Value

Sell_Signal = Cross(Risk_Low,Low); //Sell when consolidation low is broken

EC2 = tn >= Session10 AND tn <= Session11am;

EC3 = ValueWhen(Cond_LowBelowVWAP,DateTime()) < ValueWhen(Entry_Signal, DateTime()); //Only enter after vwap is crossed first

// 6. FINAL TRADE CONDITION
// ---------------------------------------------------------------


Filter = 1;//Entry_Signal AND EC2 AND Cond_PremarketVol AND GapPct_i>=3;

AddColumn( GapPct_i,        "Gap %", 1.2 );
//AddColumn(Avg20Vol,        "20D Avg Vol", 1.2);
AddColumn( DailyATR_i ,"Prior ATR", 1.2 );
AddColumn( PM_Vol,       "Premarket Vol", 1.2 );
AddColumn( First30High,        "First 30 High", 1.2 );
AddColumn( LowAfterHigh,       "Low After High", 1.2 );
AddColumn( vwap,               "VWAP", 1.2 );
AddColumn( Entry_High,          "High Entry", 1.2 );
AddColumn( Entry_Signal,          "High Signal", 1.2 );
//AddColumn( TradeSignal,        "Signal", 1.0 );
//AddColumn( BarsSinceHigh,        "BarsSince high", 1.0 );

For your goal with intraday data, you will need to use "no filtering" that way you access all your pre/post data

this block of code here.

You cannot do this, from the KB article, it is very clear how daily compression is controlled using Filtering/Trading hours. But you are setting requirements which are opposing this logic.
AB will use all the data available after the selected filtering option for daily compression.

this is the way to go, so while your trailing code should work, your start is wrong using TimeFrameSet( inDaily )

You programmatically do something like:

regular_session_start_time = 093000; // move lines to the top
regular_session_end_time = 160000;

mask_for_daily = IIf( tn >= regular_session_start_time,
					  tn < regular_session_end_time,
					  1, 0 );

daily_C = C AND mask_for_daily;
// same for O,H,L,V

// NOW, dont Compress + Expand, instead use
// HHV, LLV, SUMSINCE etc
// So you skip the TimeFrame functions

so you will be using your own created daily data expanded to your intraday timeframe.

Note: Alternate way (untested by me but theoretically doable)
IF you understand well enough, you could do a swap of standard OHLC also after applying the daily_mask. AB is very versatile.

Then use TimeFrame* functions on this data.
AmiBroker Knowledge Base » Indicators based on user values rather than standard OHLC prices
Dont forget to restore original arrays afterwards.