how to align stretchy bones

I try to align two connected Bones (using the position) to two point helper objects.

But what I get is wrong.

I googled for that issue. There are a few discussion threads on other places. But I do not understand the shown solutions.

I attach 2 files. One is a max 2016 scene and the other a maxscript file.

It would be great, if anyone could change my code (currently only 2 lines) to a compact working version with comments, which explain the added or changed lines.

I think the best starting point is to Not use the position but to emulate in any way the max inbuilt align tool functionality.

bonealign.max780 KB
bonealign.ms69 bytes