-- The indicator corresponds to the Bollinger Bands indicator in MetaTrader. -- The formula is described in the Kaufman "Trading Systems and Methods" chapter 5 "Trend System" (page 91-94) -- Indicator profile initialization routine -- Defines indicator profile properties and indicator parameters function Init() indicator:name("Bollinger Bands Decimal - Original"); indicatorescription("Original Bollinger Bands with Decimal Support"); indicator:requiredSource(core.Tick); indicator:type(core.Indicator); indicator.parameters:addDouble("N", "Number of periods", "Number of periods", 20.0); indicator.parameters:addDouble("Dev", "Number of standard deviations", "Number of standard deviations", 2.0); indicator.parameters:addColor("clrBBP", "clrBBP", "clrBBP", core.rgb(255, 0, 0)); indicator.parameters:addColor("clrBBM", "clrBBM", "clrBBM", core.rgb(0, 255, 0)); indicator.parameters:addColor("clrBBA", "clrBBA", "clrBBA", core.rgb(0, 0, 255)); end -- Indicator instance initialization routine -- Processes indicator parameters and creates output streams -- Parameters block local N; local D; local firstPeriod; local source = nil; -- Streams block local TL = nil; local BL = nil; -- Routine function Prepare() N = instance.parameters.N; D = instance.parameters.Dev; source = instance.source; firstPeriod = source:first() + N - 1; local name = "Bollinger Bands in Decimal (" .. N .. ", " .. D .. ")"; instance:name(name); TL = instance:addStream("TL", core.Line, name .. ".TL", "TL", instance.parameters.clrBBP, firstPeriod) BL = instance:addStream("BL", core.Line, name .. ".BL", "BL", instance.parameters.clrBBM, firstPeriod) AL = instance:addStream("AL", core.Line, name .. ".AL", "AL", instance.parameters.clrBBA, firstPeriod) end -- Indicator calculation routine function Update(period) if period >= firstPeriod then local p = core.rangeTo(period, N); local ml = core.avg(source, p); local d = core.stdev(source, p); TL[period] = ml + D * d; BL[period] = ml - D * d; AL[period] = ml; end end -- The indicator corresponds to the Bollinger Bands indicator in MetaTrader. -- The formula is described in the Kaufman "Trading Systems and Methods" chapter 5 "Trend System" (page 91-94) -- Indicator profile initialization routine -- Defines indicator profile properties and indicator parameters function Init() indicator:name("Bollinger Bands Decimal - Original"); indicatorescription("Original Bollinger Bands with Decimal Support"); indicator:requiredSource(core.Tick); indicator:type(core.Indicator); indicator.parameters:addDouble("N", "Number of periods", "Number of periods", 20.0); indicator.parameters:addDouble("Dev", "Number of standard deviations", "Number of standard deviations", 2.0); indicator.parameters:addColor("clrBBP", "clrBBP", "clrBBP", core.rgb(255, 0, 0)); indicator.parameters:addColor("clrBBM", "clrBBM", "clrBBM", core.rgb(0, 255, 0)); indicator.parameters:addColor("clrBBA", "clrBBA", "clrBBA", core.rgb(0, 0, 255)); end -- Indicator instance initialization routine -- Processes indicator parameters and creates output streams -- Parameters block local N; local D; local firstPeriod; local source = nil; -- Streams block local TL = nil; local BL = nil; -- Routine function Prepare() N = instance.parameters.N; D = instance.parameters.Dev; source = instance.source; firstPeriod = source:first() + N - 1; local name = "Bollinger Bands in Decimal (" .. N .. ", " .. D .. ")"; instance:name(name); TL = instance:addStream("TL", core.Line, name .. ".TL", "TL", instance.parameters.clrBBP, firstPeriod) BL = instance:addStream("BL", core.Line, name .. ".BL", "BL", instance.parameters.clrBBM, firstPeriod) AL = instance:addStream("AL", core.Line, name .. ".AL", "AL", instance.parameters.clrBBA, firstPeriod) end -- Indicator calculation routine function Update(period) if period >= firstPeriod then local p = core.rangeTo(period, N); local ml = core.avg(source, p); local d = core.stdev(source, p); TL[period] = ml + D * d; BL[period] = ml - D * d; AL[period] = ml; end endI have not used meta editor of MT4 for compiling and making .mq4 file.
I have a code which plots BB with deviation in decimal points. Pl. convert it to .mq4 file
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have a code which plots BB with deviation in decimal points. Pl. convert it to .mq4 file