Page 2 of 6

Re: Renko chart.

PostPosted: Thu Feb 17, 2011 9:48 am
by patick
Much appreciated... that fixed the problem.

Re: Renko chart.

PostPosted: Thu Feb 17, 2011 1:16 pm
by patick
whninja,

Nice work! This is the only way to do it properly to avoid brick lag/missing bricks in Market Scope.

Re: Renko chart.

PostPosted: Fri Feb 18, 2011 2:40 am
by whninja
I know, but at this time i have not the time and the skills in lua to do similar. i transfer my data to matlab for analysis.
the good is: lua and matlab are equal in scripting ...

best regards

Re: Renko chart.

PostPosted: Mon Feb 21, 2011 2:33 am
by Alexander.Gettinger
There is a feature is present in all version Renko from this topic. View of Renko chart depends on first point. For two different first points charts can look different.

Indicator Renlo2M without this feature.
Download:
Renko2M.lua
(4.57 KiB) Downloaded 2145 times

Re: Renko chart.

PostPosted: Wed Feb 23, 2011 2:21 pm
by whninja
can someone help

i had some trouble with the streams and array calc

Code: Select all
function Init()
    indicator:name("BetterRenko");
    indicator:description("BetterRenko");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);
    indicator:setTag("replaceSource", "t");

    indicator.parameters:addGroup("Calculation");
    indicator.parameters:addInteger("Step", "Step in pips", "", 10);

end

local first;
local source = nil;
local Step;
local up = nil;
local down = nil;

local n;
local i;
local open = nil;
local high = nil;
local low = nil;
local close = nil;

function Prepare()
    source = instance.source.close;
    Step=instance.parameters.Step;
    first = source:first();
    up = instance:addInternalStream(first, 0);
    down = instance:addInternalStream(first, 0);
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.Step .. ")";
    instance:name(name);
    open = instance:addStream("open", core.Line, name, "open", core.rgb(0, 0, 0), first)
    high = instance:addStream("high", core.Line, name, "high", core.rgb(0, 0, 0), first)
    low = instance:addStream("low", core.Line, name, "low", core.rgb(0, 0, 0), first)
    close = instance:addStream("close", core.Line, name, "close", core.rgb(0, 0, 0), first)
    instance:createCandleGroup("Renko", "Renko", open, high, low, close);
end

function Update(period, mode)
   if (period==source:size()-1) then

    n=1;
    up[n] = source[first];
    down[n] = source[first];

    for i=first+1,period,1 do
        local not_done;

        if n == first then
            up[n] = source[i];
            down[n] = source[i];
            n = n + 1;
        else
           
            if source[i] > up[n-1] + Step*source:pipSize() then
                up[n] = up[n-1] + Step*source:pipSize();
                down[n] = up[n-1] - Step*source:pipSize();

                n = n + 1;

                if source[i] > up[n-1] + Step*source:pipSize() then
                    not_done = 1;
                else
                    not_done = 0;
                end

                while(not_done == 1) do
                    up[n] = up[n-1] + Step*source:pipSize();
                    down[n] = up[n-1] - Step*source:pipSize();

                    n = n + 1;

                    if source[i] > up[n-1] + Step*source:pipSize() then
                        not_done = 1;
                    else
                        not_done = 0;
                    end
                end

            elseif source[i] < down[n-1] - Step*source:pipSize() then
                down[n] = down[n-1] - Step*source:pipSize();
                up[n] = down[n-1] + Step*source:pipSize();

                n = n + 1;

                if source[i] < down[n-1] - Step*source:pipSize() then
                    not_done = 1;
                else
                    not_done = 0;
                end

                while(not_done == 1) do   
                    down[n] = down[n-1] - Step*source:pipSize();
                    up[n] = down[n-1] + Step*source:pipSize();

                    n = n + 1;

                    if source[i] < down[n-1] - Step*source:pipSize() then
                        not_done = 1;
                    else
                        not_done = 0;
                    end
                end
            else
                down[n] = down[n-1];
                up[n] = up[n-1]

                n = n + 1;

            end
        end
    end

    for i=1,open:size()-1,1 do

        local m=1;
        if i < 2 then
            open[m]=nil;
            close[m]=nil;
            low[m]=nil;
            high[m]=nil;
        else
            if up[i] > up[i-1] then
                open[m]=down[i];
                close[m]=up[i];
                low[m]=down[i];
                high[m]=up[i];
                m = m + 1;

            end
            if up[i] > up[i-1] then
                open[m]=up[i];
                close[m]=down[i];
                low[m]=down[i];
                high[m]=up[i];
                m = m + 1;
            end
        end
    end
end
end

Re: Renko chart.

PostPosted: Thu Feb 24, 2011 7:39 am
by Victor.Tereschenko
whninja wrote:can someone help

i had some trouble with the streams and array calc

What king of trouble do you have? "70: Index is out of range."? This peace of code could access the "up" stream with incorrect index ("n"). "N" could become greater that the current period. You shoud add a check for correct index (n <= period).
Code: Select all
                while(not_done == 1) do
                    up[n] = up[n-1] + Step*source:pipSize();
                    down[n] = up[n-1] - Step*source:pipSize();

                    n = n + 1;

                    if source[i] > up[n-1] + Step*source:pipSize() then
                        not_done = 1;
                    else
                        not_done = 0;
                    end
                end

Re: Renko chart.

PostPosted: Thu Feb 24, 2011 2:35 pm
by whninja
thanks my problem is

n can be greater period (with a small bricksize) or n can be smaller period (with a higher bricksize)

n is the count for the bricks - in this case a higher range of a bar can have more bricks (trend)
i is a count for period/bar - in this case more bars can have only a brick (sideways)

tomorow i will swith i with (current ) period

Re: Renko chart.

PostPosted: Mon Feb 28, 2011 8:22 am
by Victor.Tereschenko
whninja wrote:thanks my problem is

n can be greater period (with a small bricksize) or n can be smaller period (with a higher bricksize)

n is the count for the bricks - in this case a higher range of a bar can have more bricks (trend)
i is a count for period/bar - in this case more bars can have only a brick (sideways)

tomorow i will swith i with (current ) period

You an array instead of internal stream.
Code: Select all
local up = {};
local down = {};
function Prepare()
...
end

instead of
Code: Select all
local up = nil;
local down = nil;
function Prepare()
...
    up = instance:addInternalStream(first, 0);
    down = instance:addInternalStream(first, 0)
...
end

Internal stream sizes/clears automatically when it is nessesary. With array you're forced to fo it manually.
Code: Select all
function Update(period, mode)
    if mode == core.UpdateAll then
        -- clear arrays
        up = {};
        ...
    end
end

Re: Renko chart.

PostPosted: Tue May 17, 2011 1:24 pm
by Pippin
Which is the most updated renko indicator? I'm new to trading with tsII as well as this site. Any help in finding the most recent renko tool will be greatly appreciated. Thanks

Re: Renko chart.

PostPosted: Wed Jan 11, 2012 1:29 pm
by TheEdge
Hello,

I don't think this is working properly...I have notice that the bars are not printing until there is a change in direction.

I have a 1hr chart with Renko set at 50pips you'll notice that price is around 250pips but there are no new bars.

This needs to be fixed. Also when using these TSII is very slow and often crashes...maybe someone could convince FXCM to have these as a standard feature as they do on Strategy Trader.