• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Convert MetaStock's Volatility Based Envelopes (VBE)

ChocolateVol

New member
I've been using with great reliability this indicator on Bloomberg (at work), and was wondering if anyone would be interested in coding it for think script. The author is Mohamed Elsaiid, former president of IFTA. The indicator was presented in this paper: https://c.mql5.com/forextsd/forum/98/volatility_based_envelopes_vbe.pdf

I've done some calculations myself in Excel but struggled with the 4th step forecasting the missing boundaries with correlations. I have to say from my own experience, this indicator beats Keltner, Bollinger, etc by far. Hope someone can crack it soon!

Quick follow up if anyone was curious to see the accuracy of the signals on a daily timeframe. Triggers are based off closing prices outside the bands.

SPX (daily)
sp.png

TSLA (daily)

tesla.png
 

rad14733

Well-known member
VIP
@ChocolateVol I did some research into VBE but was too tired the other night to attempt writing some study code... Still interested in trying at some point... I had just stumbled across a few references before the creation of this topic, which prompted me further...
 

MerryDay

Well-known member
VIP
I haven't any experience w/ VBE but this is what I had heard:
I have run across two variations of price bands that might be worth sharing. The first is volatility-based envelopes developed by Mohamed El Saiid. Like Hurst envelopes, these bands use a displaced moving average as the middle band but volatility-based standard deviation bands (like Bollinger) above and below the middle band. It gets really fancy when polynomial regressions are used to project the bands into the future. The issues are: 1) the bands are not constant width (if that matters to anyone) 2) the projections repaint in real-time, sometimes dramatically, so they are difficult to use for trading 3) The band parameter inputs do not allow longer time frames because of #2 above. They are available on several trading platforms. I have not used them.
I don't know enough about VBE bands to know if the above is true. Here is the link that I got the above quote from.
http://forum.hurstcycles.com/t/trading-with-hurst-enveloppes/94/87
 

Tradarr

New member
Can someone convert the Metastock scan to thinkscript scan, preferably the Pivot High-Low?

Domenico D’Errico’s article in this issue, “Detecting Swings,” presents four trading strategies for swing trading. Here are the MetaStock formulas for these strategies:

Strategy 1 (Pivot High-Low):

Buy Long formula:
Code:
el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));
ltrade:= If(PREV<=0, If(el, 1, 0),
If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = 1 and Ref( ltrade <= 0, -1)


Sell formula:
Code:
el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));
ltrade:= If(PREV<=0, If(el, 1, 0),
If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = -1


Sell Short formula:
Code:
el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));
strade:= If(PREV<=0, If(es, 1, 0),
If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = 1 and Ref( strade <= 0, -1)


Buy to Cover formula:
Code:
el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));
strade:= If(PREV<=0, If(es, 1, 0),
If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = -1


Strategy 2 (Bollinger Bands):

Buy Long formula:
Code:
el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);
ltrade:= If(PREV<=0, If(el, 1, 0),
If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = 1 and Ref( ltrade <= 0, -1)


Sell formula:
Code:
el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);
ltrade:= If(PREV<=0, If(el, 1, 0),
If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = -1


Sell Short formula:
Code:
el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);
strade:= If(PREV<=0, If(es, 1, 0),
If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = 1 and Ref( strade <= 0, -1)


Buy to Cover formula:
Code:
el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);
strade:= If(PREV<=0, If(es, 1, 0),
If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = -1


Strategy 3 (RSI Cross):

Buy Long formula:
Code:
el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));
ltrade:= If(PREV<=0, If(el, 1, 0),
If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = 1 and Ref( ltrade <= 0, -1)


Sell formula:
Code:
el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));
ltrade:= If(PREV<=0, If(el, 1, 0),
If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = -1


Sell Short formula:
Code:
el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));
strade:= If(PREV<=0, If(es, 1, 0),
If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = 1 and Ref( strade <= 0, -1)


Buy to Cover formula:
Code:
el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));
strade:= If(PREV<=0, If(es, 1, 0),
If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = -1


Strategy 4 (RSI & higher Low / lower High):

Buy Long formula:
Code:
el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);
ltrade:= If(PREV<=0, If(el, 1, 0),
If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = 1 and Ref( ltrade <= 0, -1)


Sell formula:
Code:
el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);
ltrade:= If(PREV<=0, If(el, 1, 0),
If(es OR (BarsSince(PREV<=0)>=4), -1, PREV));
ltrade = -1


Sell Short formula:
Code:
el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);
strade:= If(PREV<=0, If(es, 1, 0),
If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = 1 and Ref( strade <= 0, -1)


Buy to Cover formula:
Code:
el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);
strade:= If(PREV<=0, If(es, 1, 0),
If(el OR (BarsSince(PREV<=0)>=4), -1, PREV));
strade = -1
 

XeoNoX

Well-known member
VIP
@Tradarr This probably belongs in its own thread as it would be nice to keep this thread related to the VOLATILITY BASED ENVELOPES... although i know it is based of creator Metastocks, they are all different studies and ideas. To answer your question.. your requested conversion would be difficult to convert without the base code used in the references that you posted in your scan. In other words your syntaxes are referencing other syntaxes and without those syntaxes its difficult to code.
 

XeoNoX

Well-known member
VIP
gotcha, in the future i would like to convert this volatility based envelopes study, figured would try and keep it relevant. I was so happy for a split second thinking it was the code to the volatility based envelopes then i realized it wasn't. 😭 Its going to take some digging to get the formula, hopefully someone would be kind enough to at least post the formula for the volatility based envelopes.
 

Christopher84

Well-known member
VIP
The bands look just like STARC bands which are essentially Keltner channels with different settings. STARC bands are a fantastic tool for trading. They are calculated using ATR instead of standard deviation (Bollinger Bands). STARC bands come standard on the TOS platform. However, after playing around with this for a few minutes, I believe you will achieve very similar results with a Keltner channel. It just needs a some changes to the settings. (See image below) I realize its not a perfect match, but its darn close for 15 minutes of tinkering. I fail to see how this would offer any advantage over Keltner channels or STARC.

rqyCokS.png


gqsYUfY.png
 
Last edited:

Similar threads

Top