Multi Time-Frame Coding Help Needed!

Hi Guys

I am am newbie on AFL Programming and I need some help with what I am trying to accomplish here.

I am working on IntraDay Chart and my Chart's Time Interval is lets say 1 hour. I want to calculate Change in Open Interest for a particular strike and for that I need to Subtract OpenInterest that came in first tick or first minute from OpenInterest that we have now. I am trying to code like this


Ticker101 = ParamStr("Symbol 101 ", "Write Symbol 101");

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

TimeFrameSet ( in1Minute );
firstbarOfDayOpen = ValueWhen( newday, OI, 1);
firstbarOfDayOpen1 = TimeFrameExpand( firstbarOfDayOpen, in1Minute, mode = expandFirst );
Plot(firstbarOfDayOpen1, "\n"+Ticker101+" Current-OI", colorRed , styleNoDraw|styleOwnScale|styleNoLabel|styleNoLine|styleThick);

But this is not working. When I set Chart's Timeframe to 1 min numbers are okay but when i set to 15 mins or 1 hour then it changes which it should not.

Am I making some mistake here or is there a way to fix this.

Thakns guys for help !!

PLEASE NOTE that you can only compress data from shorter interval to longer interval. So when working with 1-minute data you can compress to 2, 3, 4, 5, 6, ....N-minute data. But when working with 15 minute data you can not get 1-minute data bars. In a similar way if you have only EOD data you can not access intraday time frames.

I get it. Thank You Very Much...
Is there a way I could read value of first tick of today morning on hourly chart ?

@rupen1505, would the first tick be equivalent to the "Open" value?

Intention here is to read opening value of "Open-Interest" and this does not come as an ID(Identifier) in data feed. So If I am able to ready OI from First Tick on hourly chart then mission is accomplished.

If your database interval is set to tick , you could save this information in a "non array" static variable executing a explorer with periodicity set to tick and access the stvariable from hourly chart. If your database is not tick interval but you have access to the info, the only way would be typing in the info.