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 !!