Color Regression line

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

Color Regression line

Postby Alexander.Gettinger » Mon Oct 04, 2010 9:43 pm

Unlike standard Regression indicator, Up values are red, Down values are green.

Regression_Color.png


Code: Select all
function Init()
    indicator:name("Regression color indicator");
    indicator:description("Regression color indicator");
    indicator:requiredSource(core.Tick);
    indicator:type(core.Indicator);

    indicator.parameters:addGroup("Calculation");
    indicator.parameters:addInteger("N", "Number of periods", "Number of periods", 14, 2, 1000);
    indicator.parameters:addGroup("Style");
    indicator.parameters:addColor("clrLinRegUP", "Line color UP", "Line color UP", core.rgb(255, 0, 0));
    indicator.parameters:addColor("clrLinRegDN", "Line color DN", "Line color DN", core.rgb(0, 255, 0));
    indicator.parameters:addInteger("widthLinReg", "Line width", "Line width", 1, 1, 5);
    indicator.parameters:addInteger("styleLinReg", "Line style", "Line style", core.LINE_SOLID);
    indicator.parameters:setFlag("styleLinReg", core.FLAG_LINE_STYLE);
end

local first;
local source = nil;
local n;
local Regression;
local BuffUP=nil;
local BuffDN=nil;

function Prepare()
    source = instance.source;
    n = instance.parameters.N;
    Regression = core.indicators:create("REGRESSION", source, n);
    first = Regression.DATA:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.N .. ")";
    instance:name(name);
    BuffUP = instance:addStream("BuffUP", core.Line, name .. ".UP", "UP", instance.parameters.clrLinRegUP, first);
    BuffDN = instance:addStream("BuffDN", core.Line, name .. ".DN", "DN", instance.parameters.clrLinRegDN, first);
    BuffUP:setWidth(instance.parameters.widthLinReg);
    BuffUP:setStyle(instance.parameters.styleLinReg);
    BuffDN:setWidth(instance.parameters.widthLinReg);
    BuffDN:setStyle(instance.parameters.styleLinReg);
   
end

function Update(period, mode)
   Regression:update(mode);
   if (period>first) then
    if Regression.DATA[period]>Regression.DATA[period-1] then
     BuffUP[period]=Regression.DATA[period];
     if Regression.DATA[period-1]<Regression.DATA[period-2] then
      BuffUP[period-1]=Regression.DATA[period-1];
     end
    else
     BuffDN[period]=Regression.DATA[period];
     if Regression.DATA[period-1]>Regression.DATA[period-2] then
      BuffDN[period-1]=Regression.DATA[period-1];
     end
    end
   end
   
end

Regression_Color.lua
(2.24 KiB) Downloaded 853 times

Regression_Line.lua
(3.09 KiB) Downloaded 3 times

Single Stream version.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3043
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Color Regression line

Postby sedraude » Wed Oct 06, 2010 9:26 pm

Hi Alexander,

Great indi and thanks for your work. GBU
sedraude
 
Posts: 33
Joined: Thu Aug 26, 2010 3:00 am

Re: Color Regression line

Postby sedraude » Thu Oct 07, 2010 9:05 am

Hi Alexander,

I just report, your nice indi sometimes have a broken line like this. Can you fixed it?

Thank you in advance
Image
sedraude
 
Posts: 33
Joined: Thu Aug 26, 2010 3:00 am

Re: Color Regression line

Postby Alexander.Gettinger » Thu Oct 07, 2010 3:02 pm

I don't see broken line.
Please, write me symbol and timeframe where line is broken.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3043
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Color Regression line

Postby sedraude » Thu Oct 07, 2010 11:10 pm

Alexander.Gettinger wrote:I don't see broken line.
Please, write me symbol and timeframe where line is broken.


TF M30 at EURJPY (attaches picture). (usually any TF and any pair the same problem).

When prices move back and forth, which was originally regresion line color blue color display (up) then prices go down (red), then usually there are two colors that occur and accumulate. When the price then down the rest of the blue color remained there with a broken line (vice versa). But when we reinstall this indi then it becomes normal (smooth again.).
sedraude
 
Posts: 33
Joined: Thu Aug 26, 2010 3:00 am

Re: Color Regression line

Postby bluepip » Sun Mar 06, 2011 10:16 am

Is it possible to get a strategy based on Regression Line Color changing?

Thanks
bluepip
bluepip
 
Posts: 21
Joined: Sun Jun 06, 2010 12:48 am

Re: Color Regression line

Postby Apprentice » Sun Mar 06, 2011 3:31 pm

Your request has been added in the developmental cue.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 17746
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Color Regression line

Postby Alexander.Gettinger » Wed Mar 09, 2011 12:33 am

Dot version of Color Regression line indicator.
It more suitable for use in strategy.

Download:
Regression_Color_Dot.lua
(2.26 KiB) Downloaded 509 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3043
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Color Regression line

Postby Alexander.Gettinger » Wed Mar 09, 2011 4:16 am

bluepip wrote:Is it possible to get a strategy based on Regression Line Color changing?
bluepip


Strategy, based on this indicator you may find here: viewtopic.php?f=31&t=3622
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3043
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Color Regression line

Postby Apprentice » Fri Mar 03, 2017 8:54 am

Indicator was revised and updated.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 17746
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 13 guests

cron