gani84 Posted March 4, 2014 Report Posted March 4, 2014 ' Name: Simplified Larry Williams 3 bar trailing stop ' Purpose: Trailing stop sets a stop value at the lowest low ' (or highest high) over 3 periods before the current day. ' Parameters: Periods: the number of period of lookback #Stop #Param "Periods",3 Dim myvalue as single Dim mystop as single If signal=longsignal then ' If long signal, calculate myvalue=LLV(periods)[3] ' lowest low value of last 3 bars myvalue = MAX(myvalue, 1) ' & chk that todays low is greater mystop=myvalue if L<=mystop then ' If stop level is breached signal=exitsignal ' send exit signal. end if Plotprice ("stop",mystop,green) ' Plot the stop in price pane else if signal= shortsignal then ' If short signal, calculate myvalue=HHV(periods)[3] ' highest high value of last 3 bars myvalue=MIN(myvalue,1) ' & check that todays high is lower mystop=myvalue ' than this if H>= mystop then ' If stop level is breached signal=exitsignal ' send exit signal. end if Plotprice ("stop",mystop,green) ' Plot the stop in the price pane end if
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now