Moving Average Envelopes (MAE) Customizable version.

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

Moving Average Envelopes (MAE) Customizable version.

Postby Nikolay.Gekht » Thu Apr 15, 2010 8:13 pm

There is a new customizable version of the Moving Average Envelope.

The indicator provides an ability to:
- choose the moving average method (MVA, EMA, LWMA, SMMA and so on)
- specify the band width either in 1/100 of percent or in pips.

EMA2.png


Download the indicator:
MAE2.lua
(3.68 KiB) Downloaded 3670 times


If you want to use SMMA, Vidya, Wilders smoothing method, please do not forget to download and install these indicators too.
SMMA is here viewtopic.php?f=17&t=195&p=261
Vidya is here viewtopic.php?f=17&t=301&p=570
Widlers is here viewtopic.php?f=17&t=248&p=375

Code: Select all
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
-- TODO: Add minimal and maximal value of numeric parameters and default color of the streams
function Init()
    indicator:name("Moving Average Envelope (New Version)");
    indicator:description("");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Indicator);

    indicator.parameters:addGroup("Calculation");
    indicator.parameters:addInteger("N", "Number of periods for Moving Average", "", 14);
    indicator.parameters:addString("MET", "Moving Average Method", "The methods marked by an asterisk (*) require the appropriate indicators to be loaded.", "MVA");
    indicator.parameters:addStringAlternative("MET", "MVA", "", "MVA");
    indicator.parameters:addStringAlternative("MET", "EMA", "", "EMA");
    indicator.parameters:addStringAlternative("MET", "LWMA", "", "LWMA");
    indicator.parameters:addStringAlternative("MET", "SMMA*", "", "SMMA");
    indicator.parameters:addStringAlternative("MET", "Vidya (1995)*", "", "VIDYA");
    indicator.parameters:addStringAlternative("MET", "Vidya (1992)*", "", "VIDYA92");
    indicator.parameters:addStringAlternative("MET", "Wilders*", "", "WMA");

    indicator.parameters:addInteger("B", "Band Width", "", 25);
    indicator.parameters:addString("BWU", "Band Width Units", "", "%%");
    indicator.parameters:addStringAlternative("BWU", "In 1/100 of percent", "", "%%");
    indicator.parameters:addStringAlternative("BWU", "In pips", "", "pip(s)");

    indicator.parameters:addGroup("Style");
    indicator.parameters:addBoolean("SM", "Show MA line", "", true);
    indicator.parameters:addColor("MVA_color", "Color of MA line", "", core.rgb(255, 0, 0));
    indicator.parameters:addColor("B_color", "Color of Band", "", core.rgb(0, 0, 255));
end

-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- TODO: Refine the first period calculation for each of the output streams.
-- TODO: Calculate all constants, create instances all subsequent indicators and load all required libraries
-- Parameters block
local N;
local B;
local BWU;
local MET;
local SM;

local first;
local source = nil;
local IND;

-- Streams block
local MVA = nil;
local UB = nil;
local LB = nil;

-- Routine
function Prepare()
    N = instance.parameters.N;
    B = instance.parameters.B;
    BWU = instance.parameters.BWU;
    MET = instance.parameters.MET;
    SM = instance.parameters.SM;
    source = instance.source;
    IND = core.indicators:create(MET, source, N);
    first = IND.DATA:first();

    local name = profile:id() .. "(" .. source:name() .. "," .. MET .. "(" .. N .. ")," .. B .. BWU .. ")";
    instance:name(name);

    if BWU == "%%" then
        BWU = 1;
    else
        BWU = 2;
        B = B * source:pipSize();
    end

    if SM then
        MVA = instance:addStream("MVA", core.Line, name .. ".MVA", "MVA", instance.parameters.MVA_color, first);
    end
    UB = instance:addStream("UB", core.Line, name .. ".UB", "UB", instance.parameters.B_color, first);
    LB = instance:addStream("LB", core.Line, name .. ".LB", "LB", instance.parameters.B_color, first);
end

-- Indicator calculation routine
-- TODO: Add your code for calculation output values
function Update(period, mode)
    if period >= first then
        IND:update(mode);

        local d = IND.DATA[period];
        local s;

        if BWU == 1 then
            s = d * B / 10000;
        else
            s = B;
        end

        if SM then
            MVA[period] = d;
        end
        UB[period] = d + s;
        LB[period] = d - s;
    end
end


MAE AVERAGES.lua
(4.82 KiB) Downloaded 1279 times

For, MAE averages, install Averages Indicator.
viewtopic.php?f=17&t=2430
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Moving Average Envelopes (MAE) Customizable version.

Postby twitjaksono » Mon Jun 21, 2010 11:48 pm

Wow, yes this the one that I meant. Thank you very much Sir :)
twitjaksono
 
Posts: 7
Joined: Wed May 12, 2010 11:17 pm

Re: Moving Average Envelopes (MAE) Customizable version.

Postby redkees » Thu Feb 17, 2011 11:21 am

Hi Guys,

Is it possible to get a calculation of the envelope based on the high, low and close. Ive just read Forex Trading for maximum profit by Raghee Horner and it looks like a good indi to test.

Many thanks
redkees
 
Posts: 5
Joined: Mon Sep 06, 2010 7:35 am

Re: Moving Average Envelopes (MAE) Customizable version.

Postby Apprentice » Thu Feb 17, 2011 3:48 pm

Can you tell me more about your request.

It seems to me that this is the case of Typical price.

Typical price
In financial trading, typical price (sometimes called the pivot point) refers to the arithmetic average of the high, low, and closing prices for a given period.

If this is the case.
As a source of MAE choose Typical data source.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Moving Average Envelopes (MAE) Customizable version.

Postby zaydin » Wed Jun 22, 2011 12:20 pm

hi,

this is the one that i have been looking for. thank you so much for giving a time to create this indicator. i have a question though. can you also post a signal/alert code for this indicator, so the charting program can give a signal whenver the price touches the envelope bands.
thanks for your effort again.
zaydin
 
Posts: 4
Joined: Wed Jun 22, 2011 12:17 pm


Re: Moving Average Envelopes (MAE) Customizable version.

Postby zaydin » Thu Jun 23, 2011 2:31 am

thanks for replying/ but actually it does not work/ because i use the mae2 version but the one you suggested is for mae version/ the difference is in mae version the band is calculated by the percentage value in mae2 version the band is calculated by the pips/ i was looking for the signal that would calculate the band in pips not in percentage. i would appreciate it if somebody can post a signal that would calculate the band in pips. thanks
zaydin
 
Posts: 4
Joined: Wed Jun 22, 2011 12:17 pm


Re: Moving Average Envelopes (MAE) Customizable version.

Postby zaydin » Fri Jun 24, 2011 2:55 am

dear apprentice thank you so much for your effort. i installed the signal and customized it according to my strategy and waiting for a signal:) :D hope it will work. will let you know. thank you again. with respect
zaydin
 
Posts: 4
Joined: Wed Jun 22, 2011 12:17 pm

Re: Moving Average Envelopes (MAE) Customizable version.

Postby zaydin » Mon Jul 11, 2011 7:01 am

Dear apprentice,
the signal is working just fine. the only thing is the signal waits for the hourly candle to close and then gives the signal. is it possible to modify it in a way that it gives the signal as the price touches the upper or lower band. that would have been perfected the signal :) thank you in advance
zaydin
 
Posts: 4
Joined: Wed Jun 22, 2011 12:17 pm

Next

Return to Custom Indicators

Who is online

Users browsing this forum: Bing [Bot] and 7 guests