Momentum

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

Momentum

Postby Alexander.Gettinger » Fri Apr 30, 2010 11:26 am

The Momentum Technical Indicator measures the amount that a security’s price has changed over a given time span.

Calculation:
Momentum is calculated as a ratio of today’s price to the price several (N) periods ago.

MOMENTUM = CLOSE(i)/CLOSE(i-N)*100

Where:
CLOSE(i) — is the closing price of the current bar;
CLOSE(i-N) — is the closing bar price N periods ago.

Momentum.png


Code: Select all
function Init()
    indicator:name("Momentum");
    indicator:description("Momentum");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Oscillator);
   
    indicator.parameters:addInteger("N", "N", "Period", 14);

    indicator.parameters:addColor("clrMom", "Color of momentum", "Color of momentum", core.rgb(0, 255, 0));
end

local first;
local source = nil;
local N;

function Prepare()
    source = instance.source;
    N=instance.parameters.N;
    first = source:first();
    local name = profile:id() .. "(" .. source:name() .. ", " .. N .. ")";
    instance:name(name);
    Momentum = instance:addStream("Momentum", core.Line, name .. ".Momentum", "Momentum", instance.parameters.clrMom, first);
end

function Update(period, mode)
    if (period>first+N) then
     Momentum[period]=source[period]*100./source[period-N];
    end
end

Momentum.lua
(888 Bytes) Downloaded 3904 times

Momentum Price Overlay.png

Momentum Price Overlay.lua
(5.37 KiB) Downloaded 1018 times


Simple momentum strategy.
viewtopic.php?f=31&t=65737&p=117765#p117765
EURSEK H1 (02-15-2018 1140).png

Detrended Momentum.lua
(4.3 KiB) Downloaded 621 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Momentum

Postby Alexey » Tue Nov 29, 2011 8:16 pm

Hello,

What about CMO oscillator in FXCM Marketscope ?
Isn't it the same thing ?

Regards,
Alexey
 
Posts: 4
Joined: Sun Nov 20, 2011 4:51 pm

Re: Momentum

Postby Apprentice » Thu Dec 01, 2011 8:54 am

They are not.
Formula for Momentum
source[period]*100/source[period-N];

Formula for CMO

diff = source[period] - source[period - 1];

if diff > 0 then
cmo1[period] = diff;
elseif diff < 0 then
cmo2[period] = -diff;
end

s1 = mathex.sum(cmo1, p, period);
s2 = mathex.sum(cmo2, p, period);
CMO[period] = (s1 - s2) / (s1 + s2) * 100;
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Momentum

Postby Alexey » Thu Dec 01, 2011 11:40 am

So CMO isn't the old & classical Momentum known by every one ? It is another oscillator ?
Alexey
 
Posts: 4
Joined: Sun Nov 20, 2011 4:51 pm

Re: Momentum

Postby Apprentice » Fri Dec 02, 2011 5:56 pm

Yes, As the difference in the name suggests.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Momentum

Postby xpertizetrading » Thu May 28, 2015 10:44 am

Is it possible to code a Momentum Price Overlay, Similar to RSI Price overlay, as we have on fxcodebase?

Thanks,
Xpertize Trading
xpertizetrading
 
Posts: 60
Joined: Fri Nov 22, 2013 12:30 pm

Re: Momentum

Postby Apprentice » Sun Jun 07, 2015 3:38 am

Momentum Price Overlay.lua Added.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Momentum

Postby Apprentice » Thu Feb 15, 2018 7:47 am

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


Return to Custom Indicators

Who is online

Users browsing this forum: Google [Bot] and 62 guests