Fans of variable number of MA, CCI, RSI, RLW, 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

Fans of variable number of MA, CCI, RSI, RLW, Momentum

Postby Alexander.Gettinger » Tue May 25, 2010 3:38 am

Fan of EMA.

Fan_EMA.png


Code: Select all
function Init()
    indicator:name("FAN of EMA");
    indicator:description("");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Indicator);

    indicator.parameters:addInteger("Period_1", "First period", "No description", 5);
    indicator.parameters:addString("Method", "Method", "", "Add");
    indicator.parameters:addStringAlternative("Method", "Add", "", "Add");
    indicator.parameters:addStringAlternative("Method", "Mult", "", "Mult");

    indicator.parameters:addInteger("K", "K", "No description", 2);
    indicator.parameters:addInteger("N", "Count of MA", "No description", 5);

end

local Period1;
local K;
local N;
local Method;

local first;
local source = nil;
local buffs={};

local Inds={};

function Prepare()
    Period1 = instance.parameters.Period_1;
    K = instance.parameters.K;
    N = instance.parameters.N;
    Method = instance.parameters.Method;
    source = instance.source;
    local Period=Period1;
    for i=1,N,1 do
     Ind=core.indicators:create("EMA", source, Period);
     Inds[i]=Ind;
     if Method=="Mult" then
      Period=Period*K;
     else
      Period=Period+K;
     end
    end
   
    first = Inds[N].DATA:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. Period1 .. ", " .. K .. ", " .. N .. ", " .. Method .. ")";
    instance:name(name);
   
    for i=1,N,1 do
     if i<N/3 then
      Color=core.rgb(i*155*3/N+100,0,0);
     elseif i>=N/3 and i<2*N/3 then
      Color=core.rgb(0,(i-N/3)*155/N+100,0);
     else
      Color=core.rgb(0,0,(i-N*2/3)*155/N+100);
     end
     buffs[i] = instance:addStream("buff" .. i, core.Line, name .. ".buff" .. i, "buff" .. i, Color, first);
    end
end

function Update(period, mode)
 if (period>first) then
  for i=1,N,1 do
   Inds[i]:update(mode);
   buffs[i][period]=Inds[i].DATA[period];
  end
 
 end
end

Fan_MA.lua
(1.88 KiB) Downloaded 1654 times

MT4/Mq4 veersion is available here.
viewtopic.php?f=38&t=63780
Last edited by Alexander.Gettinger on Tue May 25, 2010 3:51 am, edited 1 time in total.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Fans of variable number of MA, CCI, RSI

Postby Alexander.Gettinger » Tue May 25, 2010 3:40 am

Fan of CCI.

Fan_CCI.png


Code: Select all
function Init()
    indicator:name("FAN of CCI");
    indicator:description("");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);

    indicator.parameters:addInteger("Period_1", "First period", "No description", 5);
    indicator.parameters:addString("Method", "Method", "", "Add");
    indicator.parameters:addStringAlternative("Method", "Add", "", "Add");
    indicator.parameters:addStringAlternative("Method", "Mult", "", "Mult");

    indicator.parameters:addInteger("K", "K", "No description", 2);
    indicator.parameters:addInteger("N", "Count of CCI", "No description", 5);

end

local Period1;
local K;
local N;
local Method;

local first;
local source = nil;
local buffs={};

local Inds={};

function Prepare()
    Period1 = instance.parameters.Period_1;
    K = instance.parameters.K;
    N = instance.parameters.N;
    Method = instance.parameters.Method;
    source = instance.source;
    local Period=Period1;
    for i=1,N,1 do
     Ind=core.indicators:create("CCI", source, Period);
     Inds[i]=Ind;
     if Method=="Mult" then
      Period=Period*K;
     else
      Period=Period+K;
     end
    end
   
    first = Inds[N].DATA:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. Period1 .. ", " .. K .. ", " .. N .. ", " .. Method .. ")";
    instance:name(name);
   
    for i=1,N,1 do
     if i<N/3 then
      Color=core.rgb(i*155*3/N+100,0,0);
     elseif i>=N/3 and i<2*N/3 then
      Color=core.rgb(0,(i-N/3)*155/N+100,0);
     else
      Color=core.rgb(0,0,(i-N*2/3)*155/N+100);
     end
     buffs[i] = instance:addStream("buff" .. i, core.Line, name .. ".buff" .. i, "buff" .. i, Color, first);
    end
end

function Update(period, mode)
 if (period>first) then
  for i=1,N,1 do
   Inds[i]:update(mode);
   buffs[i][period]=Inds[i].DATA[period];
  end
 
 end
end


Fan_CCI.lua
(1.88 KiB) Downloaded 1176 times

MT4/Mq4 veersion is available here.
viewtopic.php?f=38&t=63791
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Fans of variable number of MA, CCI, RSI

Postby Alexander.Gettinger » Tue May 25, 2010 3:41 am

Fan of RSI.

Fan_RSI.png


Code: Select all
function Init()
    indicator:name("FAN of RSI");
    indicator:description("");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Oscillator);

    indicator.parameters:addInteger("Period_1", "First period", "No description", 5);
    indicator.parameters:addString("Method", "Method", "", "Add");
    indicator.parameters:addStringAlternative("Method", "Add", "", "Add");
    indicator.parameters:addStringAlternative("Method", "Mult", "", "Mult");

    indicator.parameters:addInteger("K", "K", "No description", 2);
    indicator.parameters:addInteger("N", "Count of RSI", "No description", 5);

end

local Period1;
local K;
local N;
local Method;

local first;
local source = nil;
local buffs={};

local Inds={};

function Prepare()
    Period1 = instance.parameters.Period_1;
    K = instance.parameters.K;
    N = instance.parameters.N;
    Method = instance.parameters.Method;
    source = instance.source;
    local Period=Period1;
    for i=1,N,1 do
     Ind=core.indicators:create("RSI", source, Period);
     Inds[i]=Ind;
     if Method=="Mult" then
      Period=Period*K;
     else
      Period=Period+K;
     end
    end
   
    first = Inds[N].DATA:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. Period1 .. ", " .. K .. ", " .. N .. ", " .. Method .. ")";
    instance:name(name);
   
    for i=1,N,1 do
     if i<N/3 then
      Color=core.rgb(i*155*3/N+100,0,0);
     elseif i>=N/3 and i<2*N/3 then
      Color=core.rgb(0,(i-N/3)*155/N+100,0);
     else
      Color=core.rgb(0,0,(i-N*2/3)*155/N+100);
     end
     buffs[i] = instance:addStream("buff" .. i, core.Line, name .. ".buff" .. i, "buff" .. i, Color, first);
    end
end

function Update(period, mode)
 if (period>first) then
  for i=1,N,1 do
   Inds[i]:update(mode);
   buffs[i][period]=Inds[i].DATA[period];
  end
 
 end
end

Fan_RSI.lua
(1.88 KiB) Downloaded 1202 times

MT4/Mq4 veersion is available here.
viewtopic.php?f=38&t=63789
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Fans of variable number of MA, CCI, RSI

Postby zmender » Sun Jan 22, 2012 4:23 pm

Would it be possible to show only two moving averages, and shade the areas in between them?

http://www.forex-tsd.com/indicators-met ... bon-3.html
zmender
 
Posts: 43
Joined: Thu Nov 10, 2011 11:00 pm


Re: Fans of variable number of MA, CCI, RSI

Postby zmender » Mon Jan 23, 2012 2:24 pm

exactly what i was looking. Thank you!
zmender
 
Posts: 43
Joined: Thu Nov 10, 2011 11:00 pm

Re: Fans of variable number of MA, CCI, RSI

Postby Hailkayy » Sat Feb 04, 2012 10:20 pm

Funny Apprentice, you make too good indicators, which one am i supposed to use now ? :mrgreen: :lol:
Hailkayy
FXCodeBase: Initiate
 
Posts: 191
Joined: Thu Dec 22, 2011 4:42 am

Re: Fans of variable number of MA, CCI, RSI

Postby Apprentice » Sun Feb 05, 2012 3:06 am

I really would not know.
I only write them, do not use them in my trading.
I can explain some theoretical basis,
However forum is not appropriate medium.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Fans of variable number of MA, CCI, RSI

Postby Hailkayy » Sun Feb 05, 2012 9:39 am

O.K tell me where i can write you so that, i can ask you some questions, and discuss a bit about trading and indi's. Just one or two message about general trading.
Just reply when ur off work or when u have time. Exchanging ideas really appreciated.
Thank you.
Hailkayy
FXCodeBase: Initiate
 
Posts: 191
Joined: Thu Dec 22, 2011 4:42 am


Next

Return to Custom Indicators

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 41 guests