PureBytes Links
Trading Reference Links
|
I am trying to write an indicator that displays a trailing stop as a fixed
percentage of the closing price, but never goes lower, only higher (for long
positions).
The following seems to do the job for long positions, giving a 10% fixed
stop:
If((C*0.9) >= PREV, (C*0.9), PREV);
Next, I tried to apply the same idea to short positions with:
If((C*1.1) <= PREV, (C*1.1), PREV);
The intention was to plot a stop value that was 10% above the close, but
never to be raised higher than the previous day's value.
The second formula plots a line with a constant value of zero, presumably
because the initial value of PREV is zero, and the value of C*1.1 is never
less than that. I've tried several alternate approaches, but seem to keep
coming back to the same problem of needing to use PREV.
I'm stuck, so any ideas would be appreciated. Is this simply another
limitation of the language?
Thanks,
Barry
|