- Katılım
- 23 Eki 2020
- Mesajlar
- 1,828
Trailing Stop Indicator Dilemma . To: <metastock@xxxxxxxxxxxxx> . Subject: Trailing Stop Indicator Dilemma . From: "Barry Marx" <bmarx@xxxxxxxxx> . Date: Wed, 5 May 1999 01:26:01 -0400 . Reply-To: metastock@xxxxxxxxxxxxx . Sender: owner-metastock@xxxxxxxxxxxxx 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 [13743] Re: Trailing Stop Indicator Dilemma . To: <metastock@xxxxxxxxxxxxx> . Subject: Re: Trailing Stop Indicator Dilemma . From: "VonHef" <VonHef@xxxxxxxxxxxxx> . Date: Wed, 5 May 1999 07:18:52 -0500 . Organization: Microsoft Corporation . References: <01be96b7$c3897660$10754d0c@xxxxx> . Reply-To: metastock@xxxxxxxxxxxxx . Sender: owner-metastock@xxxxxxxxxxxxx Hi Barry, Try this: |
|
Trailing Stop Indicator III by Adam Hefner If(cum(1)=1, {then} Close, {else} If((C*1.1) <= PREV, {then}(C*1.1), {else} PREV)); |
|