Earnings dates in GetFnData("Aux1"), how to get number of days/bars until next and from previous earnings?
This is related to https://forum.amibroker.com/t/plot-earnings-dates/589
I scraped historical earnings dates, and imported them to aux1 field as 1, so my sample quote data for Apple looks like this:
Ticker Date Close Open High Low Volume Open Int. Aux1 Aux2 EOD
AAPL 5/1/2018 169.1 166.4102 169.2 165.27 535693.8 0 1 0 EOD
AAPL 4/30/2018 165.26 162.1302 167.26 161.84 424274.3 0 0 0 EOD
I would like to run an exploration but need help figuring out how to make use of GetFnData("Aux1")
- My first pertinent afl line with
TodayEarnings = IIf ( GetFnData("Aux1") == 1, 1, 0);
throws
IIf ( GetFnData(------------------------^ .... Unsupported field
when running an exploration - How can I count today's bar to next aux1, also accounting for NO future quote or aux1 always being 0?
- How can I count today's bar to previous aux1, also accounting for NO past quote or aux1 always being 0?
This is the start to my afl code:
TodayEarnings = IIf ( GetFnData("Aux1") == 1, 1, 0); // If Aux1 is 1 then earnings are on today's bar
NextEarnings = 1; // in days from entry day, how to calculate today's bar to next aux1, also accounting for NO future quote/aux1?
PreviousEarnings = 1; // in days from entry day, how to calculate today's bar to previous aux1?
AddColumn ( TodayEarnings, "TodayEarnings", 1.0);
AddColumn ( NextEarnings, "NextEarnings", 1.0);
AddColumn ( PreviousEarnings, "PreviousEarnings", 1.0);