# 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)

TSLA (daily)

##### 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...

#### ChocolateVol

##### New member
@rad14733 that's great, appreciate the effort!

Posting below additional notes from the one who coded this for BBERG

#### 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.

#### Namor

##### New member
Is there any way in TOS to create price envelopes akin to those found in Metastock?

##### Well-known member
VIP
Is there any way in TOS to create price envelopes akin to those found in Metastock?

Do you have an image...??? I don't have MetaStock...

#### XeoNoX

##### Well-known member
VIP
just subbing so i dont forget to look at this better when im not sleeeepy, seeems intersting

#### Namor

##### New member
Do you have an image...??? I don't have MetaStock...
It's just a moving average band with a vertical shift percentage (ex. 1.5 vertical shift)

##### 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):

Code:
``````el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));

Sell formula:
Code:
``````el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));

Sell Short formula:
Code:
``````el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));

Code:
``````el:= Ref(H, -1) > Max( H, Ref(H, -2));
es:= Ref(L, -1) < Min( L, Ref(L, -2));

Strategy 2 (Bollinger Bands):

Code:
``````el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);

Sell formula:
Code:
``````el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);

Sell Short formula:
Code:
``````el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);

Code:
``````el:= Cross( C, BBandBot(C, 20, S, 2));
es:= Cross( BBandTop(C, 20, S, 2), C);

Strategy 3 (RSI Cross):

Code:
``````el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));

Sell formula:
Code:
``````el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));

Sell Short formula:
Code:
``````el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));

Code:
``````el:= Cross( RSI(5), 40);
es:= Cross( 60, RSI(5));

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

Code:
``````el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);

Sell formula:
Code:
``````el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);

Sell Short formula:
Code:
``````el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -1);

Code:
``````el:= RSI(5) < 40 AND L > Ref(L, -1);
es:= RSI(5) > 60 AND H < Ref(H, -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.

#### BenTen

Staff
VIP
@XeoNoX I moved it here because we already covered a lot of those items throughout this site. If @Tradarr spends some time looking through the forum, he should be able to find things like RSI cross scanner and pivot high-low. They may not be exactly the same but adjustment can easily be added.

#### 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.

#### XeoNoX

##### Well-known member
VIP
superbowl time, ill read through this tomorrow or following day

#### ChocolateVol

##### New member
superbowl time, ill read through this tomorrow or following day
The first post in the thread includes a link to the published paper with a description of the math behind it

#### 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.

Last edited: