\mymacro is a standard TeX macro: it does not matter at all that it includes
\directlua. As such, the standard rules for replacement of material apply. When you define
"#1 4", you are telling it to substitute in
#1, then a blank space, then a
4. So its entirely to be expected that the space appears in the output.
As was indicated in a comment, TeX only allows up to nine arguments to a macro (and indeed working with a macro with nine arguments is pretty awkward). As such, you should miss out the space here or write your definition such that you use additional lines to divide up concepts