FXCM Forex Trading

Double Bollinger Band

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

Double Bollinger Band

Postby Nikolay.Gekht » Mon Aug 22, 2011 2:19 pm

Just a double Bollinger band indicator used in The Little Book of Currency Trading by Kathy Lien

Please see explanations how to use it
http://www.investopedia.com/articles/fo ... z1VmdUeyAw

This indicator is equal to putting just two BB indicators on the same chart, but is a little bit less resource eating and can highlight the zone between inner and outer bands for easier interpretation

dbb.png


Download:
Double Bollinger Band
dbb.lua
(4.33 KiB) Downloaded 2521 times

Triple Bollinger Bands
tbb.lua
(5.94 KiB) Downloaded 1047 times


TBB with Alert.lua
(21.46 KiB) Downloaded 373 times

Dec 10, 2015: Compatibility issue Fix. _Alert helper is not longer needed.

Source:
Code: Select all
function Init()
    indicator:name("Double Bollinger Bands");
    indicator:description("");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Indicator);
    indicator:setTag("group", "Bollinger");

    indicator.parameters:addGroup("Calculation");
    indicator.parameters:addInteger("N", "Number of periods", "", 20, 1, 10000);
    indicator.parameters:addDouble("D1", "Deviation for inner band", "", 1.0, 0.00001, 10000);
    indicator.parameters:addDouble("D2", "Deviation for outer band", "", 2.0, 0.00001, 10000);
    indicator.parameters:addGroup("Style");
    indicator.parameters:addInteger("MS", "Midline Style", "", core.LINE_SOLID);
    indicator.parameters:setFlag("MS", core.FLAG_LEVEL_STYLE);
    indicator.parameters:addInteger("MW", "Midline Width", "", 1, 1, 5);
    indicator.parameters:addColor("MC", "Midline Color", "", core.rgb(255, 0, 255));

    indicator.parameters:addInteger("IS", "Inner Band Style", "", core.LINE_SOLID);
    indicator.parameters:setFlag("IS", core.FLAG_LEVEL_STYLE);
    indicator.parameters:addInteger("IW", "Inner Band Width", "", 1, 1, 5);
    indicator.parameters:addColor("IC", "Inner Band Color", "", core.rgb(127, 0, 0));

    indicator.parameters:addInteger("OS", "Outer Band Style", "", core.LINE_SOLID);
    indicator.parameters:setFlag("OS", core.FLAG_LEVEL_STYLE);
    indicator.parameters:addInteger("OW", "Outer Band Width", "", 1, 1, 5);
    indicator.parameters:addColor("OC", "Outer Band Color", "", core.rgb(255, 128, 64));

    indicator.parameters:addBoolean("HF", "Highlight Area Between Bands", "", true);
    indicator.parameters:addColor("HC", "Highligh Area Color", "", core.rgb(255, 255, 0));
    indicator.parameters:addInteger("HT", "Highlight Area Trasnsparency", "0 - opaque, 100 - transparent", 80, 0, 100);
end

local N, D1, D2;
local first;
local source;
local M, OU, OD, IU, ID, OU1, OD1, IU1, ID1;
local HF;

function Prepare(onlyName)
    local name = profile:id() .. "(" .. instance.source:name() .. "," .. instance.parameters.N .. "," ..  instance.parameters.D1 .. ","  .. instance.parameters.D2 .. ")";
    instance:name(name);
    if onlyName then
        return ;
    end
    source = instance.source;
    N = instance.parameters.N;
    D1 = instance.parameters.D1;
    D2 = instance.parameters.D2;
    first = source:first() + N - 1;

    M = instance:addStream("Mid", core.Line, name .. ".Mid", "Mid", instance.parameters.MC, first);
    M:setStyle(instance.parameters.MS);
    M:setWidth(instance.parameters.MW);
    IU = instance:addStream("InUp", core.Line, name .. ".InUp", "InUp", instance.parameters.IC, first);
    IU:setStyle(instance.parameters.IS);
    IU:setWidth(instance.parameters.IW);
    ID = instance:addStream("InDn", core.Line, name .. ".InDn", "InDn", instance.parameters.IC, first);
    ID:setStyle(instance.parameters.IS);
    ID:setWidth(instance.parameters.IW);
    OU = instance:addStream("OutUp", core.Line, name .. ".OutUp", "OutUp", instance.parameters.OC, first);
    OU:setStyle(instance.parameters.OS);
    OU:setWidth(instance.parameters.OW);
    OD = instance:addStream("OutDn", core.Line, name .. ".OutDn", "OutDn", instance.parameters.OC, first);
    OD:setStyle(instance.parameters.OS);
    OD:setWidth(instance.parameters.OW);

    HF = instance.parameters.HF;

    if HF then
        IU1 = instance:addInternalStream(first, 0);       
        ID1 = instance:addInternalStream(first, 0);       
        OU1 = instance:addInternalStream(first, 0);       
        OD1 = instance:addInternalStream(first, 0);       
        instance:createChannelGroup("U", "U", OU1, IU1, instance.parameters.HC, 100 - instance.parameters.HT);
        instance:createChannelGroup("D", "D", ID1, OD1, instance.parameters.HC, 100 - instance.parameters.HT);
    end
end

function Update(period, mode)
    if period >= first then
        local m = core.avg(source, period - N + 1, period);
        local d = mathex.stdev(source, period - N + 1, period);

        M[period] = m;
        IU[period] = m + d * D1;
        ID[period] = m - d * D1;
        OU[period] = m + d * D2;
        OD[period] = m - d * D2;
        if HF then
            IU1[period] = m + d * D1;
            ID1[period] = m - d * D1;
            OU1[period] = m + d * D2;
            OD1[period] = m - d * D2;
        end
    end
end


MT4/MQ4 version
viewtopic.php?f=38&t=64446
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1222
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Double Bollinger Band

Postby bedayan » Tue Nov 15, 2011 3:01 am

Is it possible for code this thing for triple bollinger band? I require triple bollinger band.
bedayan
 
Posts: 6
Joined: Tue Nov 15, 2011 2:55 am

Re: Double Bollinger Band

Postby Apprentice » Tue Nov 15, 2011 3:29 am

While you wait, you can try Multiple Bollinger Bands.
viewtopic.php?f=17&t=1319&p=5262&hilit=multiple+bullinger#p5262
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 15383
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Double Bollinger Band

Postby Apprentice » Tue Nov 15, 2011 5:07 am

Triple Bollinger Bands added.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 15383
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Double Bollinger Band

Postby followNev » Mon Mar 05, 2012 10:13 am

Hi,
I am using the DBB indicator and it works really well when I screen my ccy pairs.
Has anyone created an automated strategy for this that we can download ?
followNev
 
Posts: 2
Joined: Fri Feb 10, 2012 1:45 pm
Location: London

Double Bollinger Band

Postby LauraZ » Tue Mar 06, 2012 2:36 am

always in the market ssytem. signal, cross of middle band of bollinger band and MA

no need for stat analysis for this one its being used to make the cross points clearer for a wider arrayed trading systems
LauraZ
 
Posts: 1
Joined: Thu Feb 16, 2012 1:46 pm

Re: Double Bollinger Band

Postby Apprentice » Tue Mar 06, 2012 4:22 am

Which algorithm do you want to use this strategy
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 15383
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Double Bollinger Band

Postby followNev » Thu Mar 08, 2012 8:26 am

Apprentice wrote:Which algorithm do you want to use this strategy


is it possible to create a new algo for this ?
I have an idea of how I'd like the algo to work, would I have to pay for the code ?

thanks
followNev
 
Posts: 2
Joined: Fri Feb 10, 2012 1:45 pm
Location: London

Re: Double Bollinger Band

Postby Coondawg71 » Mon Nov 11, 2013 5:13 pm

Can we please add a request to the development que regarding the Triple Bollinger Band indicator.

I would like to see a Signal with Alert capacity upon each breach of Deviation Level.

For example, attached image highlights breach of 2.0 deviation.
Ideally, alert would send signal upon each breach of the triple bollinger band. like 1.0, 1.62, 2.0.

Thanks,

sjc
Attachments
single period bb extremes.png
Single Period Triple Bollinger Band Deviation Alert
User avatar
Coondawg71
FXCodeBase: Graduate
 
Posts: 325
Joined: Sat Jan 15, 2011 11:45 am

Re: Double Bollinger Band

Postby Apprentice » Tue Nov 12, 2013 4:16 am

TBB with Alert added.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 15383
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Custom Indicators

Who is online

Users browsing this forum: Majestic-12 [Bot], Yahoo [Bot] and 6 guests