I've got this rigging technical question. Ive got this rig 90% complete and for the most part it is working on one plane. The issue I am having is that I need the "lower arm" to twist with the x movement. Pictured below. So basically I need to have that red part know when the end point of the IK chain modes side to side and twist that part of the arm to keep it mechanically functional.
Here is the scene file with some screenshots: