Barsoomian
New member
I'm writing a strategy and one of the conditions is I want it to trigger a sell to close a buy trade just before earnings. At the time I wrote it, I assumed the HasEarnings would return true all day long:
In the daily chart, it works for both PM earnings same day and AM earnings next day.
In the hourly chart, the PM earnings check works correctly on the last bar on the day of earnings. However, the pre-market earnings check only returns true for the 1.30pm bar (CST) if there are earnings the next day (tested with DIS and U recently), and it returns false for the 2.30pm bar. I could get rid of lastDailyBar and just trigger a sell at the end of the 1.30pm bar, not a big difference I'm sure, but I'd like to know if this is consistent and known behavior for the pre-market earnings check or if it's a bug.
Code:
input sellPreEarnings = yes;
def lastDailyBar = if (GetDay()!=GetDay()[-1]) then yes else no;
def earnings = sellPreEarnings and lastDailyBar and (HasEarnings(EarningTime.BEFORE_MARKET)[-1] or HasEarnings(EarningTime.AFTER_MARKET));
def sell = earnings or (blah blah other events);
In the daily chart, it works for both PM earnings same day and AM earnings next day.
In the hourly chart, the PM earnings check works correctly on the last bar on the day of earnings. However, the pre-market earnings check only returns true for the 1.30pm bar (CST) if there are earnings the next day (tested with DIS and U recently), and it returns false for the 2.30pm bar. I could get rid of lastDailyBar and just trigger a sell at the end of the 1.30pm bar, not a big difference I'm sure, but I'd like to know if this is consistent and known behavior for the pre-market earnings check or if it's a bug.
Last edited by a moderator: