We do not have enough data on this route to provide a reliable graph showing how many days before departure it is the best to book.
However, usually the closer it is to the departure, the more expensive the tickets are.
The cheapest flights you can book on the route Barajas (MAD) - Dortmund Airport (DTM).
There is no direct flight on the route Madridból Dortmundba
The shortest flights with change last about 10h 10min.