In my view it's between 1798 and 1815. So between the French invasion of Egypt (a huge wakeup call that showed the Ottomans they needed to reform) and the end of the Napoleonic wars, which had been providing a distraction to the Ottoman's enemies. Unfortunately, this period was also one of great turbulence inside the empire, and much energy had to be spent on quashing the rash of revolts in this same period.
Though it's possible that if Nader Shah doesn't get malaria in India, he could provide a demonstration of Ottoman shortcomings on a similar scale to Napoleon. Or if Catherine the Great had more success in convincing the Hapsburgs to join her in an anti-Ottoman alliance and Russia and Austria give the Ottomans a drubbing in their heartlands before the French Revolution distracts Christian Europe...
As I see it, the big issue is that while the Ottomans were falling to keep ahead of Christian Europe over the 18th Century, they started from such a high point that they were able to coast for a long time. So it's necessary to give them both a serious wake-up call AND to marry that with a period of calm so that the Sultan and the civil service can focus on getting reform to take root.
fasquardon
For your point, the Ottomans did this. The Russian conquest of the Crimea and the fall of Egypt to France showed how vunerable the Empire was. The failure was Selim III response to the Janissary Coup in Istanbul. The coup was a garrison of a fortress, no more than a hundred, maybe a bit more, something that could be crushed by loyal newly formed troops. Selim III failed to react and when he did he gave command to the wrong persons (Köse Musa being a traitor). Had Selim ordered an attack on the revolters it was already over and the reforms would be 30 years earlier. This is also the period that Mehmed Ali of Egypt is not powerful yet...
Nader Shah's beatings would have helped had he conquered Baghdad and maybe even Diyarbakir. It would hardly be enough to threaten Anatolia as it would mean a bigger campaing and more resources but the beatings would give Istanbul a wake up call. The Janissaries don't help anymore and the Sipahis are outdated as well. The Ottomans have a better position to reconquer Baghdad during or after Naders rule.
The biggest issue the Ottomans had in the 18th century was good sultans. There were a few (Ahmed III, Mustafa III, Selim III) But between Ahmed III and Selim III, the Sultans were mentally not the best Sultans as they were kept in the palace with no clue what happens in the world. The worst being Osman III who had spent 50 years as a 'captive' but he barely ruled for three years. A disaster would be complete if the Russian war was during his reign. A Sultan of Selim III or Mustafa II capacity in the bigger part of the 18th century would be enough to keep the Empire stronger. In the absence of a good Sultan, the Grand Vizier solved the issues which were also absent in the Empire. You can't always have a Köprülü Mehmed Pasha...