Gann HiLo Activator

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Gann HiLo Activator

Postby Apprentice » Thu Dec 31, 2009 12:19 pm

Image

On Metatrader platform I use Gann HiLo Activator indicator,
very useful indicator.

Looking for developers who can encod Gann HiLo Activator indicator for MarketScope

Gann HiLo Activator is basically a simple moving average of the previous 3 periods' highs or lows plotted based in relation to the HiLo Activator.

Gann High Low - Metastock Indicator Formula
by Adam Hefner
{name: GANN-HiLo}

HLd:=If(CLOSE>Ref(Mov(H,3,S),-1),
{then}1,
{else}If(CLOSE<Ref(Mov(L,3,S),-1),
{then}-1,
{else}0));
HLv:=ValueWhen(1,HLd<>0,HLd);
HiLo:=If(HLv=-1,
{then}Mov(H,3,S),
{else}Mov(L,3,S));
HiLo;


Apprentice
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36478
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Gann HiLo Activator

Postby TonyMod » Mon Jan 04, 2010 3:40 pm

Hello Apprentice,

I forwarded your request to the developers. They said they will try to get this indicator done for you this week. One of us will post it as soon as its done.

Cheers.
Best Regards,

"TonyMod"
(FXCodeBase.com Forum Moderator)
TonyMod
FXCodeBase: Site Admin
 
Posts: 70
Joined: Wed Oct 21, 2009 1:57 pm
Location: New Jersey

Re: Gann HiLo Activator

Postby Nikolay.Gekht » Mon Jan 04, 2010 6:35 pm

If I understand the Metaquotes code correctly, the indicator displays simple moving average for the last N (i.e. including the current) periods of either High or Low values.
In case current close value is greater than average high of previous N periods, the indicator shows average low value. In case the current close is less than average low of the previous N periods, the indicator shows average high value. In case the close is neither greater previous than average high nor less than previous average low, the indicator chooses High or Low to show as it was for the previous period.

The indicator which works in that logic is attached. Could you please check whether it's the indicator you need.

Download (Corrected to 10 periods as per user's suggestion):
GHLA.lua
Gann Hi-Lo indicator in .Lua
(2.27 KiB) Downloaded 933 times


Code: Select all
-- Indicator profile initialization routine
function Init()
    indicator:name("Gann High Low Activator");
    indicator:description("No description");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);

    indicator.parameters:addInteger("N", "Number of Periods", "", 3);
    indicator.parameters:addColor("GHLA_color", "Color of the Line", "", core.rgb(255, 0, 0));
end

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

-- Streams block
local GHLA = nil;   -- indicator result
local pdir = nil;   -- the previous direction

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

    local name = profile:id() .. "(" .. source:name() .. ", " .. N .. ")";
    instance:name(name);
    GHLA = instance:addStream("GHLA", core.Line, name, "GHLA", instance.parameters.GHLA_color, first);
    pdir = instance:addInternalStream(0, 0);
end

-- Indicator calculation routine
function Update(period)
    pdir[period] = 0;
    if period >= first and source:hasData(period) then
   -- calculate average high and low for the previous N periods (excluding the current).
        local range = core.rangeTo(period - 1, N);
        local avgh, avgl;
        local switch = 0;
        avgh = core.avg(source.high, range);
        avgl = core.avg(source.low, range);
   -- change direction in case the current close is above average high
        -- or below average low
        if (source.close[period] > avgh) then
            switch = 1;
        elseif (source.close[period] < avgl) then
            switch = -1;
        end       
        if (switch ~= 0) then
       -- remember the direction in case we have to switch
            pdir[period] = switch;
            dir = switch;
        else
       -- or use the previous direction
            dir = pdir[period - 1];
        end
        -- and get average of the last N high or low values depending on the direction
        range = core.rangeTo(period, N);
        if (dir == -1) then
            GHLA[period] = core.avg(source.high, range);
        else
            GHLA[period] = core.avg(source.low, range);
        end
    end
end


Snapshot:
ghla.png
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Gann HiLo Activator

Postby Apprentice » Tue Jan 05, 2010 4:46 am

Thanks guys for the effort, the indicator is perfect,
I recommend using 10 periods, as the default value.

You can use it to generate buy and sell signals and set stop loss orders.
I use it along with the ADX, QQE indicators, QQE can be replaced with RSI or TSI.

You can use it for all time frames.

Apprentice
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36478
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Gann HiLo Activator

Postby rkardatzke » Sun Jul 18, 2010 9:02 pm

is there a signal available for this indicator ?
rkardatzke
 
Posts: 7
Joined: Sun Jul 18, 2010 8:49 pm

Re: Gann HiLo Activator

Postby Apprentice » Mon Jul 19, 2010 1:37 am

Such signal was not yet written.
Added to the Development cue.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36478
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia



Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 35 guests