FXCM Forex Trading

FRASMA

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

FRASMA

Postby Alexander.Gettinger » Tue Jul 27, 2010 2:32 am

Fractally Modified Simple Moving Average.

The SMA is accelerated during a trend and slowed down during a sideways market, so as to avoid false signals.

Frasma.png


Code: Select all
function Init()
    indicator:name("FRASMA indicator");
    indicator:description("FRASMA indicator");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Indicator);
   
    indicator.parameters:addInteger("e_period", "e_period", "e_period", 30);
    indicator.parameters:addInteger("normal_speed", "normal_speed", "normal_speed", 20);

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

local first;
local source = nil;
local e_period;
local normal_speed;

function Prepare()
    source = instance.source;
    e_period=instance.parameters.e_period;
    normal_speed=instance.parameters.normal_speed;
    first = source:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.e_period .. ", " .. instance.parameters.normal_speed .. ")";
    instance:name(name);
    FRASMA = instance:addStream("FRASMA", core.Line, name .. ".FRASMA", "FRASMA", instance.parameters.clr, first);
end

function Update(period, mode)
    if (period>first+e_period) then
     local priceMax=core.max(source,core.rangeTo(period,e_period));
     local priceMin=core.min(source,core.rangeTo(period,e_period));
     local length=0.;
     local priorDiff=0.;
     local diff=0.;
     for i=0,e_period-2,1 do
      if priceMax>priceMin then
       diff=(source[period-i]-priceMin)/(priceMax-priceMin);
       if i>0 then
        length=length+math.sqrt(math.pow(diff-priorDiff,2)+(1./math.pow(e_period,2)));
       end
       priorDiff=diff;
      end
     end
     local fdi=0.;
     if length>0. then
      fdi=1.+(math.log(length)+math.log(2.))/math.log(2.*e_period);
     end
     local trail_dim=1./(2.-fdi);
     local alpha=trail_dim/2.;
     local speed=math.floor(normal_speed*alpha);
     FRASMA[period]=core.avg(source,core.rangeTo(period,speed));
    end
end
Attachments
Frasma.lua
(1.84 KiB) Downloaded 592 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 2518
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: FRASMA

Postby Coondawg71 » Thu Nov 29, 2012 5:41 pm

Can this indicator please be update to INCLUDE the indicator window below the price chart as shown in this attached illustration.

Thanks,

sjc

http://codebase.mql4.com/5308
User avatar
Coondawg71
FXCodeBase: Graduate
 
Posts: 325
Joined: Sat Jan 15, 2011 11:45 am

Re: FRASMA

Postby Apprentice » Fri Nov 30, 2012 2:52 am

If you try to add this indicator to MT4,
you'll notice that these are in fact two different indicators.
Ones below can be found here.
viewtopic.php?f=17&t=26614&p=46376&hilit=FDI#p46376
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 15156
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: FRASMA

Postby Apprentice » Mon Apr 17, 2017 6:51 am

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


Return to Custom Indicators

Who is online

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