My experience was the opposite of Bert's closer to the frame extrusions eliminated the problem for me (and some shielding). A suggestion for anyone trying to troubleshoot would be to watch the Octoprint terminal while the machine is printing and move the cables and observe the results and do what works best for your particular situation.
@Bert_Magin are you powering your Octo using the printers power supply or a seperate??
In my case I am powering a Raspberry Pi from the Printers PS using a buck converter.
I'm wondering if the power source could be what is causing this to be the opposite??
I will add my experience here in the case it might help someone else. Due to space constraints my printer is not in an ieal location and having a pi also plugged in to the wall outlet as well as the printer was not ideal.
I have an Ender 3 pro with the honeywell 16a PSU, so i figured thats more than sufficient to reliably power the printer and the rpi4 b+. after a few weeks of mucking around, its sorted. initially i was having voltage issues and communications drop outs. I was using a LM2596 buck convertor from AliEx; i persisted with this for a bit and solved the comms issues by replacing the usb cable i was using. I soldered 20AWG wires to the gpio pins on the pi to see if i could resolve the low voltage error. still nothing; i should mention that i had a genuine rpi psu and would constantly plug it back it to make sure that everything was still working as required when on a steady supply (obvs disconnecting the buck before hand).
then i read somewhere about a UBEC, which converts variable voltage down to 5v 3a, so i ordered one of those and it came with pretty skinny wires and a ferrite ring. wired this in and the pi seemed to work fine but was still having low voltage error but printed fine and no failed prints because of it. Then i decided to try and get rid of the voltage error so i unsoldered the skinny wires that it came with and soldered on some 20AWG and got it all back up and it had solved the low voltage error. however i would get a comms drop out at the first layer change of prints. exact same spot each time.
Solved one issues, caused another. In my haste of rewiring the convertor i had forgotton to add the little ferrite ring back onto the new cables, lucky for me i had added an inline deutsch plug so i could quickly put the ring back on.
finally got the rpi reliably powered and printing from the printers PSU, no comms or voltage issues.