That is an interesting idea. I tend to be very wary of having a stop loss calculated from another security because it adds another level of complexity to what should be a clear decision. Regardless I’m curious about what parameters you are wanting to change.
If it was length based, I’d calculate both of them.
a14 = ATR(bars=14);
a20 = ATR(bars=20);
then get the data of the security
x1 = GETDATA(CODE=XAO:WI);
now we can do an if on that. Let’s just say if the 10 day change is positive we use the a20 level, but when it turns down we tighten the stop (that’s actually a smart idea if that is what you were thinking).
a1 = if(CHANGE(x1, bars = 10) IsUp, a20, a14);
Now we subtract that from the close and apply a ratchet so it can not go down - you just need to set the start date for the ratchet function.
You have certainly pointed me in the right direction, and I will muck around with this code over the weekend and see if I can get it to do what I want it to.
Yes, the idea is to tighten the trailing stop when the XAO starts to show any weakness, and loosen it when it's "strong".