carlvan

Ensign volatility stop

Category: Indicators By: carlvan Created: January 4, 2022, 9:01 AM
January 4, 2022, 9:01 AM
Indicators
4 Comments
Ensign volatility stop

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[1](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
else
between = 0
endif

if close>hiline or (high > high[1] and high > hiline) then
up = 1
else
up = 0
endif

if close < loline or (low < low[1] and low < loline) then
dn = 1
else
dn = 0
endif

if between and barssince(up) < barssince(dn) then
upcond = 1
else
upcond = 0
endif

if between and barssince(dn) < barssince(up) then
dncond = 1
else
dncond = 0
endif

if up or upcond then
upline = loline
r1= 0
g1= 0
b1= 255

else
upline = upline[1]
r1=255
g1=255
b1=255
endif

if dn or dncond then
dnline= hiline
r3=255
g3=0
b3=0
else
dnline = dnline[1]
r3=255
g3=255
b3=255
endif

return upline coloured(r1,g1,b1) as "Upline", dnline coloured(r3,g3,b3)as "DownLine"

 

 

Download
Filename: Ensign-volatility-stop.itf
Downloads: 418
carlvan
carlvan Average
Currently debugging life, so my bio is on hold. Check back after the next commit for an update.
Author’s Profile

Comments

Denis
4 years ago
#

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

CederTrader
4 years ago
#

Hi Denis, does this indicator add to the chart as panel, or on the candles. Thanks

Nicolas
4 years ago
#

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/

Denis
4 years ago
#

Hello, 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

ProRealCode ProRealCode
Loading...