I create a 'Return on investment' column in the option chain to compare profitability of selling puts, the script is as following
def DTE = GetDaysToExpiration()-1;
def Strikeprice = GetStrike();
def ROI = bid/Strikeprice/DTE*360;
AddLabel(yes,AsPercent(ROI));
I notice that the output number become inaccurate on weekends, because on Saturday or Sunday, the calculation for this 'Day to Expiration' won't deduct weekend days, and stay as if it were still on last Friday. Is there a way to modify the script so when it is Saturday, DTE would minus 1 day; And when it is on Sunday, DTE would minus 2 days
In plain words, It would look something like
def DTE = if weekdays then GetDaysToExpiration()-1 else if Saturday then GetDaysToExpiration()-2 else if Sunday then GetDaysToExpiration()-3
def DTE = GetDaysToExpiration()-1;
def Strikeprice = GetStrike();
def ROI = bid/Strikeprice/DTE*360;
AddLabel(yes,AsPercent(ROI));
I notice that the output number become inaccurate on weekends, because on Saturday or Sunday, the calculation for this 'Day to Expiration' won't deduct weekend days, and stay as if it were still on last Friday. Is there a way to modify the script so when it is Saturday, DTE would minus 1 day; And when it is on Sunday, DTE would minus 2 days
In plain words, It would look something like
def DTE = if weekdays then GetDaysToExpiration()-1 else if Saturday then GetDaysToExpiration()-2 else if Sunday then GetDaysToExpiration()-3