Stochastic Rainbow

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

Re: Stochastic Rainbow

Postby ThemBonez » Mon Mar 05, 2012 3:36 pm

That's great....now with the StochRSI :)
ThemBonez
FXCodeBase: Initiate
 
Posts: 127
Joined: Sat Mar 20, 2010 1:56 pm

Re: Stochastic Rainbow

Postby ThemBonez » Mon Mar 05, 2012 3:38 pm

...and the Rainbow.
ThemBonez
FXCodeBase: Initiate
 
Posts: 127
Joined: Sat Mar 20, 2010 1:56 pm

Re: Stochastic Rainbow

Postby ThemBonez » Tue Mar 06, 2012 6:27 pm

Hi,
I made an effort to make the changes myself but it will not load. I can't see where the error is. Can you check it over for me and show me where the error is and make the correction. The lua file is attached as well as the code below
Thank You

Code: Select all
function Init()
    indicator:name("StochasticRSI Fibo Rainbow indicator");
    indicator:description("StochasticRSI Fibo Rainbow indicator");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);

    indicator.parameters:addGroup("Calculation");
    indicator.parameters:addInteger("K_Period", "Initial K_Period", "", 5);
    indicator.parameters:addInteger("K_Slowing", "Initial K_Slowing", "", 3);
    indicator.parameters:addInteger("D_Slowing", "Initial D_Slowing", "", 3);
    indicator.parameters:addInteger("RSI_Period", "RSI_Period", "", 8);

    indicator.parameters:addGroup("Style");
     indicator.parameters:addGroup("Style");
    indicator.parameters:addColor("clr1", "Color 1", "Color 1", core.rgb(0, 0, 128));
    indicator.parameters:addColor("clr2", "Color 2", "Color 2", core.rgb(0, 0, 255));
    indicator.parameters:addColor("clr3", "Color 3", "Color 3", core.rgb(0, 128, 0));
    indicator.parameters:addColor("clr4", "Color 4", "Color 4", 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 K_Slowing;
local D_Period;
local D_Slowing;
local FiboK;
local Ind_St={};
local St={};

function Prepare()
    source = instance.source;
    K_Period=instance.parameters.K_Period;
    K-Slowing=instance.parameters.K_Slowing;
    D_Slowing=instance.parameters.D_Slowing;
    RSI_Period=instance.parameters.RSI_Period;
    first = source:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.RSI_Period .. ", " .. instance.parameters.K_Period .. ", " .. instance.parameters.K_Slowing .. ", " .. instance.parameters.D_Slowing .. ")";
    local K_P=K_Period;
    local K_S=K_Slowing;
    local D_S=D_Slowing;
    FiboK=(1+math.sqrt(5))/2;
    for i=1,RSI_Period,1 do
     Ind_St[i]=core.indicators:create("STOCHASTICRSI", source, K_P, K_S, D_P,"MVA","MVA");
     K_P=math.floor(K_P*FiboK+0.5);
     K_S=math.floor(K_S*FiboK+0.5);
     D_S=math.floor(D_S*FiboK+0.5);
     St[i]=instance:addStream("St" .. i, core.Line, name .. ".St" .. i, "St" .. i, instance.parameters.clr, first);
     St[i]:setWidth(instance.parameters.widthLinReg);
     St[i]:setStyle(instance.parameters.styleLinReg);
    end
end

function Update(period, mode)
   if (period>first) then
    for i=1,RSI_Period,1 do
     Ind_St[i]:update(mode);
     St[i][period]=Ind_St[i].D[period];
    end
   end
end



Attachments
Stochastic_RSI Fibo Rainbow.lua
(2.63 KiB) Downloaded 679 times
ThemBonez
FXCodeBase: Initiate
 
Posts: 127
Joined: Sat Mar 20, 2010 1:56 pm

Re: Stochastic Rainbow

Postby Apprentice » Thu Mar 08, 2012 6:24 am

Corrected a few problems.
You have to fix a few more.
Algorithm for random color.
You can have unlimited number of colors.
But you can not have so many color parameters.

Second, the parameters that you are passing to STOCHASTICRSI are not valid.
Stochastic_RSI Fibo Rainbow.lua
(2.89 KiB) Downloaded 692 times


If you write what you want to achieve, I can finish this job for you.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Stochastic Rainbow

Postby ThemBonez » Thu Mar 08, 2012 7:05 am

I look at 4 different StochRSI charts with the below parameters. I liked the concept of the Stochastic Rainbow you created.

I would like 4 stochrsi lines with the following parameters based on Fibonacci Sequence:
8,5,3,3
13,8,5,5
21,13,8,8
34,21,13,13

(Parameters = RSI Periods, %K Stochastic Periods, %K SLowing Periods, %D Slowing Stochastic Periods)

Each line a different color.

On the right side of chart 70 and 30 lines.

If you could finish it for me, that would be great!
Thanx!
ThemBonez
FXCodeBase: Initiate
 
Posts: 127
Joined: Sat Mar 20, 2010 1:56 pm

Re: Stochastic Rainbow

Postby Alexander.Gettinger » Thu Mar 08, 2012 9:54 am

ThemBonez wrote:Each line a different color.

On the right side of chart 70 and 30 lines.


Stochastic_Fibo_Rainbow2.lua
(3.04 KiB) Downloaded 924 times

Stochastic_RSI Fibo Rainbow2.lua
(3.1 KiB) Downloaded 976 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic Rainbow

Postby Apprentice » Mon Apr 03, 2017 6:43 am

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

Previous

Return to Custom Indicators

Who is online

Users browsing this forum: No registered users and 82 guests