Combining SparseCompress and TimeFrameSet

Hello,

I am trying to test systems with custom sessions.

I have 1 minut data, but also need calculation from higher timeframe.

Can you please hint me how to combine SparseCompres and TimeFrameSet?

I was trying to calculate Daily Open of Sparsed data this way:

tn = TimeNum();
CS = tn >= 093000 AND tn < 142900;

TimeFrameSet( inDaily);

DailyO=SparseExpand(CS,SparseCompress(CS, Open ));
TimeFrameRestore();

Plot(TimeFrameExpand( DailyO,inDaily), "DailyO", colorYellow ); 

Which is not working. Can you please hint me how to do this task correctly?
Thank you.

Hm, what's the difference to your other thread of today


which would save you from programming headaches? In addition some system metrics would not include disregarded bars into calculations.

How about something like this:

tn = TimeNum();
dn = DateNum();
CS = tn >= 093000 AND tn < 142900;
isStartOfDay = CS AND (!Ref(CS,-1) OR dn != Ref(dn,-1));
dailyOpen = ValueWhen(isStartOfDay, Open);
1 Like

I would like to be able to optimize the session. That is why I want to control it using the code.

Thank you @mradtke I will go perhaps this way. I was overall mostly checking if there is some easier way using timeframeset so I could use the higher timeframe data also in some indicators.