The write off occurs in the operating year the expense occurred not the transaction. This allows you to write off for trips where nothing came out of it as well because if you had to close and could only report it then, you'd never be able to report trips you didn't close on.
If we're talking about purchasing a flip property, and you're already in the flipping business - then yes. If we're talking about purchasing a rental property in the area where you already have another one - the answer is also yes.
But I suspect you're talking about a new rental property in a new area, or maybe even your very first investment property. Then the answer is no. It will have to be added to the purchase cost in 2018 and depreciated.
Thanks, @Michael Plaks !