DeMarker Oscillator [Upd Nov, 03 10]

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

DeMarker Oscillator [Upd Nov, 03 10]

Postby admin » Tue Oct 20, 2009 5:25 pm

DESCRIPTION:
DeMarker indicator compares the most current price action to the previous period’s price to determine the demand of the instrument in question. Usually this indicator identifies price exhaustion and also can identify market highs and lows.

PURPOSE OF "DeMarker":
For most part, traders use DeMarker for indentifying the risk of the levels in which they place a transaction. Values over 60 are indicators of lower volatility and lower risk, when on other had reading lower than 40 usually indicates that risk is increasing.

UPDATES
Nov, 03 2010, ng: new feature:
1) Choice for smoothing method (MVA, EMA and so on)
2) Choice for line style
3) Choice for levels and level drawing styles

DeMarker.jpg
DeMarker Screenshot.


DOWNLOAD:
(last version)
dem.lua
Download "DeMarker" Oscillator (new version).
(4.54 KiB) Downloaded 1979 times

(previous version)

Code: Select all
-- initializes the indicator
function Init()
    indicator:name("DeMarker");
    indicator:description("")
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);

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

    indicator.parameters:addGroup("Style");
    indicator.parameters:addColor("C", "Color", "", core.rgb(0, 127, 127));
    indicator.parameters:addInteger("W", "Width", "", 1, 1, 5);
    indicator.parameters:addInteger("S", "Style", "", core.LINE_SOLID);
    indicator.parameters:setFlag("S", core.FLAG_LINE_STYLE);

    indicator.parameters:addGroup("Levels");
    indicator.parameters:addDouble("Level1", "Low Risk Level", "", 0.6, 0, 1);
    indicator.parameters:addDouble("Level2", "High Risk Level", "", 0.4, 0, 1);
    indicator.parameters:addColor("LC", "Main level color", "", core.rgb(0, 127, 127));
    indicator.parameters:addInteger("LW", "Main level width", "", 2, 1, 5);
    indicator.parameters:addInteger("LS", "Main level style", "", core.LINE_DOT);
    indicator.parameters:setFlag("LS", core.FLAG_LINE_STYLE);
    indicator.parameters:addColor("LC1", "Aux level color", "", core.rgb(0, 127, 127));
    indicator.parameters:addInteger("LW1", "Aux level width", "", 1, 1, 5);
    indicator.parameters:addInteger("LS1", "Aux level style", "", core.LINE_DOT);
    indicator.parameters:setFlag("LS1", core.FLAG_LINE_STYLE);
end

local source;
local first;
local out;
local max;
local min;
local smax;
local smin;
local n;

-- process parameters and prepare for calculations
function Prepare()
    assert(core.indicators:findIndicator(instance.parameters.MA) ~= nil, "Please download and install " ..  instance.parameters.MA .. ".lua");

    n = instance.parameters.N;
    source = instance.source;

    max = instance:addInternalStream(source:first() + 1);
    min = instance:addInternalStream(source:first() + 1);
    smax = core.indicators:create(instance.parameters.MA, max, n);
    smin = core.indicators:create(instance.parameters.MA, min, n);
    first = smax.DATA:first();
    name = profile:id() .. "(" .. source:name() .. "," .. instance.parameters.MA  .. "," .. n .. ")";
    instance:name(name);
    out = instance:addStream("DeM", core.Line, name .. ".DeM", "DeM", instance.parameters.C, first);
    out:setWidth(instance.parameters.W);
    out:setStyle(instance.parameters.S);
    out:addLevel(0, instance.parameters.LS1, instance.parameters.LW1, instance.parameters.LC1);
    out:addLevel(instance.parameters.Level2, instance.parameters.LS, instance.parameters.LW, instance.parameters.LC);
    out:addLevel(0.5, instance.parameters.LS1, instance.parameters.LW1, instance.parameters.LC1);
    out:addLevel(instance.parameters.Level1, instance.parameters.LS, instance.parameters.LW, instance.parameters.LC);
    out:addLevel(1, instance.parameters.LS1, instance.parameters.LW1, instance.parameters.LC1);
end

-- Indicator calculation routine
function Update(period, mode)
    if (period > source:first() + 1) then
        if (source.high[period] > source.high[period - 1]) then
            max[period] = source.high[period] - source.high[period - 1]
        else
            max[period] = 0;
        end
        if (source.low[period] < source.low[period - 1]) then
            min[period] = source.low[period - 1] - source.low[period];
        else
            min[period] = 0;
        end
    end
    smax:update(mode);
    smin:update(mode);
    if (period >= first) then
        local vmax;
        local vmin;
        vmax = smax.DATA[period];
        vmin = smin.DATA[period];
        if (vmax == 0 and vmin == 0) then
            out[period] = nil;
        else
            out[period] = vmax / (vmax + vmin);
        end
    end
end


Tags: DeMarker, indicator, Marketscope, oscillator, Trading Station, FXCM, dbFX
admin
FXCodeBase: Site Admin
 
Posts: 20
Joined: Tue Oct 20, 2009 10:02 am
Location: Paramus, NJ

Re: DeMarker Oscillator [Upd Nov, 03 10]

Postby Nikolay.Gekht » Wed Nov 03, 2010 7:04 pm

updated
1) choice for smoothing method
2) line styles
3) levels and level styles
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: DeMarker Oscillator [Upd Nov, 03 10]

Postby Jeffreyvnlk » Mon Sep 15, 2014 1:41 am

Nikolay.Gekht wrote:updated
1) choice for smoothing method
2) line styles
3) levels and level styles

Appreciated if you could give an edited version with no smoothing
Jeffreyvnlk
FXCodeBase: Graduate
 
Posts: 302
Joined: Wed Apr 11, 2012 2:17 pm


Re: DeMarker Oscillator [Upd Nov, 03 10]

Postby Jeffreyvnlk » Wed Sep 17, 2014 2:19 pm

Apprentice wrote:
dem without smoothing.lua


Fantastic. Thank Apprentice !
Jeffreyvnlk
FXCodeBase: Graduate
 
Posts: 302
Joined: Wed Apr 11, 2012 2:17 pm

Re: DeMarker Oscillator [Upd Nov, 03 10]

Postby Apprentice » Mon Mar 05, 2018 2:33 pm

The Indicator was revised and updated.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36437
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Custom Indicators

Who is online

Users browsing this forum: No registered users and 113 guests