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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
//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" |
Share this
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
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
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