_:nb921c128ee8e4d1289cf5fd671be8111xb9
<http://schema.org/text>
"I do not know what symbol or timeframe you are having problems with the above code. I combined the code I provided you and it seems to be working.\n\nIf you are still having problems, it could be because you must be using at least a chart of the number of trading days to get the \"X/Y\" code to work. TOS, other than with most built-in functions (eg: counttradingdays, daysfromdate) seems to only work on custom codes (eg: \"X, X_Date, Y, Y_Date) if the data required for these is present in chart being displayed (eg: 22 trading days will require a chart likely set at least 30 days of data)..\n\nHere is a chart of JBLU set at 15min, 30 days, and everything appears ok\n\n\n\nHere is the same chart of JBLU set at 15min, 10 days, and there are problems with the custom code (Y and Y-Date), but not the built-in functions\n\n\n\nHere is the combined code used in both of the above.\n\nI agree the above code works...The code doesn't work when I use X_date and Y_date ;basically calculating the number of days from high to low.\ndef num_trading_days  = absValue(CountTradingDays(X_Date, Y_Date));\ndef num_calendar_days = absvalue(DaysFromDate(X_Date) - DaysFromDate(Y_Date) + 1);"
<https://usethinkscript.com/threads/count-trading-days-from-the-current-bar-to-today.870/>