I'm taking a stab at writing script.
I want it to sum up the total buy volume and sell volume since last earnings.
I'm getting an error: "Only constants expected here: PastEarnings CL constant function parameter 'length' at 10:58" . Why is that?
Am I even on the right track?
I want it to sum up the total buy volume and sell volume since last earnings.
Code:
# Define the earnings date offset
def Earnings = AbsValue(GetEventOffset(Events.Earnings, -1));
def PastEarnings = if isNaN(Earnings)
then 0
else Earnings;
# Calculate buy and sell volumes since the last earnings date
def buyVolume = Sum(if close > open then volume else 0, PastEarnings);
def sellVolume = Sum(if close < open then volume else 0, PastEarnings);
# Add chart label for buy and sell volumes
AddLabel(yes, "Buy Volume: " + buyVolume + " | Sell Volume: " + sellVolume, Color.WHITE);
I'm getting an error: "Only constants expected here: PastEarnings CL constant function parameter 'length' at 10:58" . Why is that?
Am I even on the right track?