It’s legal to trade of course, the question is deductibility vs the wash sale rule delaying your loss being realized. The above link gets to the heart of the question from OP - what is “substantially identical” and potentially also what is a “security”?
On the “substantially identical” front, there is good IRS case law to say that trading in the same stock, or options in that stock, will generate wash sales. Options are not however substantially identical to different options on the same stock, ie Mar $100 calls vs Apr $100 calls are obviously not identical or even substantially so having different terms. A different ETF or futures contract would definitely not be identical for these purposes - they almost certainly don’t have the same holdings in the same amounts for example, even if many are similar. There’s a decent case for example that two different SP500 tracking ETFs are not substantially identical under a careful reading of the tax law. Whether you’d win if someone wanted to take that to tax court on a close case like that is less clear, but i don’t hear about many wash sale audits.
and then there’s the question of what is a “security”. Stock, mutual funds/ETFs, and options on those. There are lots of things that
aren’t securities that trade on the exchanges. Futures, publicly traded partnerships (like UNG for example), grantor trusts (GLD), etc. there are no wash sales applied to these things (although that might change in the proposed $3.5T tax bill), although of course your broker might be too dumb to know the difference between an exchange traded grantor trust like GLD and a stock and put a wash sale incorrectly on your 1099 for you to fix if you care.
many commodity and in particular natural gas “ETFs” are not structured in a way that makes them securities. For example, UNG is a publicly traded partnership (PTP) and those don’t have wash sales at least per this tax discussion, which agrees with my understanding.
https://ttlc.intuit.com/community/b...ordinary-gain-then-bought-then-back/00/692374
if I was OP and wanted to avoid a wash sale, I might switch to a similar futures exposure or a different nat gas ETF just to avoid the headache if my broker flagged a cover and re-short in the same PTP as a wash sale even if it shouldn’t be.