FXCM Forex Trading

Fractal-based Support/Resistance Lines

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

Fractal-based Support/Resistance Lines

Postby Nikolay.Gekht » Wed Feb 17, 2010 5:30 pm

The simple indicator which starts a new support/resistance line every time when up or down fractal appears.

fbrs.png


Code: Select all
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
function Init()
    indicator:name("Fractal Based Support/Resistance lines");
    indicator:description("");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);

    indicator.parameters:addColor("R_color", "Color of R", "Color of R", core.rgb(255, 192, 0));
    indicator.parameters:addColor("S_color", "Color of S", "Color of S", core.rgb(0, 192, 255));
end

-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- Parameters block
local first;
local source = nil;

-- Streams block
local R = nil;
local S = nil;

-- Routine
function Prepare()
    source = instance.source;
    first = source:first() + 4;

    local name = profile:id() .. "(" .. source:name() .. ")";
    instance:name(name);
    R = instance:addStream("R", core.Dot, name .. ".R", "R", instance.parameters.R_color, first);
    S = instance:addStream("S", core.Dot, name .. ".S", "S", instance.parameters.S_color, first);
end

-- Indicator calculation routine
function Update(period)
    if period >= first and source:hasData(period) then
        -- defect fractals on two periods ago
        local up, down, curr;
        up = false;
        down = false;
        curr = source.high[period - 2];
        if (curr >= source.high[period - 4] and curr >= source.high[period - 3] and
            curr >= source.high[period - 1] and curr >= source.high[period]) then
            up = true;
        end
        if up then
            R[period - 2] = curr;
            R[period - 1] = curr;
            R[period] = curr;
        else
            if R:hasData(period - 1) then
                R[period] = R[period - 1];
            end
        end
        curr = source.low[period - 2];
        if (curr <= source.low[period - 4] and curr <= source.low[period - 3] and
            curr <= source.low[period - 1] and curr <= source.low[period]) then
            down = true;
        end
        if down then
            S[period - 2] = curr;
            S[period - 1] = curr;
            S[period] = curr;
        else
            if S:hasData(period - 1) then
                S[period] = S[period - 1];
            end
        end
    end
end


Download:
FBSR.lua
(2.31 KiB) Downloaded 5379 times


FBSR with Fibonacci levels
FBSR_With_Fib.lua.png

FBSR_With_Fib.lua
(7.79 KiB) Downloaded 1010 times
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1230
Joined: Wed Dec 16, 2009 6:39 pm
Location: Morrisville, NC

Re: Fractal-based Support/Resistance Lines

Postby kytkable » Wed Oct 20, 2010 11:09 am

Hi,
I am a new one. My English is not well.
So many people download the indicator.
It shows that is very useful and helpful.Very thanks to
the worker and fxcodebase.com. I have a request, if
possible, Could anyone show me how to change the
R/S line form "....." to "____"?

Very thanks
kytkable
 
Posts: 1
Joined: Tue Apr 13, 2010 5:52 am

Re: Fractal-based Support/Resistance Lines

Postby thetruth » Wed Nov 03, 2010 8:03 am

if you need lines only have to change core.Dot for core.Line in function prepare in lines
R= and S=.

Code: Select all
function Prepare()
    source = instance.source;
    first = source:first() + 4;

    local name = profile:id() .. "(" .. source:name() .. ")";
    instance:name(name);
    --core.Dot=core.Line
   R = instance:addStream("R", core.Line, name .. ".R", "R", instance.parameters.R_color, first);
    S = instance:addStream("S", core.Line, name .. ".S", "S", instance.parameters.S_color, first);
end
thetruth
 
Posts: 41
Joined: Thu Feb 25, 2010 3:39 pm

Re: Fractal-based Support/Resistance Lines

Postby kelvincha » Sun Dec 19, 2010 10:46 am

Good Job
That almost the best indicator ever
but I have a request
can i change the resistance and support to fiboncci retracement level of previous day
Thanks a lot
kelvincha
 
Posts: 2
Joined: Sat Dec 04, 2010 9:15 am

Re: Fractal-based Support/Resistance Lines

Postby Apprentice » Sun Dec 19, 2010 10:59 am

It is possible, but then it will be quite a different indicator.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 8753
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Fractal-based Support/Resistance Lines

Postby Nikolay.Gekht » Mon Dec 20, 2010 11:53 am

kelvincha wrote:Good Job
That almost the best indicator ever
but I have a request
can i change the resistance and support to fiboncci retracement level of previous day
Thanks a lot

Hm... As far as I see, this can be done just using PIVOT indicator. Choose "Fibonacci Retarement" in the mode, choose the levels you need and switch the historical mode "on" if you need to see historical levels.
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1230
Joined: Wed Dec 16, 2009 6:39 pm
Location: Morrisville, NC

Re: Fractal-based Support/Resistance Lines

Postby TradeKing » Fri Feb 25, 2011 3:41 pm

How do we change this indicator to lines instead of dots? I see it posted that we have to change core.dot from dot to lines but I don't even know where that would be done. Can someone please assist or change the indicator please. Thanks!

TradeKing
TradeKing
 
Posts: 9
Joined: Fri Feb 25, 2011 3:25 pm

Re: Fractal-based Support/Resistance Lines

Postby Apprentice » Sat Feb 26, 2011 5:51 am

Something like this.
FBSR.lua
(2.71 KiB) Downloaded 1333 times
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 8753
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Fractal-based Support/Resistance Lines

Postby TradeKing » Wed Mar 02, 2011 2:43 pm

Perfect! Thank you very much!
TradeKing
 
Posts: 9
Joined: Fri Feb 25, 2011 3:25 pm

Re: Fractal-based Support/Resistance Lines

Postby dollar » Fri Apr 08, 2011 1:13 am

I have downloaded and transfered FBSR.Lua to my tradestation platform however it does not have this appearance as there are also vertical lines connecting to the horizonal lines which are very distracting and make the chart very busy. Is there a way for the code to be changed so that only the horizonal lines appear? The example would fit my eye very nicely for support and resistance only. THANK YOU in advance. Gene Dollar
dollar3539@yahoo.com
dollar
 
Posts: 1
Joined: Fri Apr 08, 2011 1:00 am

Next

Return to Custom Indicators

Who is online

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