Idea for trailing stop

 

Can someone code a trailing stop indicator in the style of the parabolic SAR.

Modifying the existing code of the parabolic may be a shortcut to getting the idea working.

So, if the condition is "long", then we want the stop moved to the midpoint of the lows of the two previous bars.

the psuedo code::: val = (low(-1) - low(-2))/2 + low(-2);

and if, the condition is "short", then we want the stop moved to the midpoint of the highs of the two previous bars.

the psuedo code::: val = (high(-2) - high(-1))/2 + high(-1);

It should act like the current parabolic where the long/short dots are drawn as the stop is hit. SAR.

Happy coding

Reason: