This is a code converted from AFL and based on a volatility stop originally developed by Ensign, now public domain.
Benefit of this stop: parametrable “elasticity” in order to avoid early stop-out within existing trend- this stop “absorbs” the inevitable little pullbacks of the prices.
But, drawbacks of my converted code – and here I am keenfully awaiting the help of Nicolas:
it takes literally forever for the code to chart (45 secondes of calculation on my very fast machine) before charting. And when using Defparam calculate on last x bars, it doesn’t help really. Is there a way to make this code much quicker?
I didn’t find the equivalent of AFL “Null” instructions: in this case, it would be used in the calculation of upline and dnline for the value given after the “else” condition. “Null” then generates NO plotting of the indicator. Due to that, I had to use the “coloured” params to try make the indicator invisible on the chart (white colour on a white background chart) but it is not very “handsome”
Enjoy this nice indicator, and thank you for any improvement/help.
PRT code for EnsignVolatStop
//Defparam Calculateonlastbars = 6000
VSraw = k * exponentialaverage[period](AverageTrueRange(close))
// for longs, VS line is below price
loline = HIGHEST[PERIOD](CLOSE) - VSraw
// for shorts, VS line is above price
hiline = LOWEST[period](Close) + VSraw
if close < hiline and close > loline then
between = 1
between = 0
if close>hiline or (high > high and high > hiline) then
up = 1
up = 0
if close < loline or (low < low and low < loline) then
dn = 1
dn = 0
if between and barssince(up) < barssince(dn) then
upcond = 1
upcond = 0
if between and barssince(dn) < barssince(up) then
dncond = 1
dncond = 0
if up or upcond then
upline = loline
upline = upline
if dn or dncond then
dnline = dnline
return upline coloured(r1,g1,b1) as "Upline", dnline coloured(r3,g3,b3)as "DownLine"
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.ProRealTime ITF files and other attachments :
PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Very interesting indicator, many thanks.
But I confirm that it takes way too long to load, a minute or more.
When I activate Defparam by deleting “//”, nothing appears.
Nicolas, you who are always a great help, do you have an idea to solve this problem please?
Thanking you in advance for your precious help
Hi Denis, does this indicator add to the chart as panel, or on the candles. Thanks
Add it on the price chart as described in this video: https://www.prorealcode.com/blog/video-tutorials/how-to-add-an-indicator-on-price-prorealtime/
Hello Nicolas and Ceder Trader,
Sorry, I only just saw your replies.
The indicator is already well established on the prices, so the problem does not come from there