Daystart vertical 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

Daystart vertical line

Postby Nikolay.Gekht » Mon Dec 12, 2011 3:51 pm

The simple indicator which just draws a vertical line at the beginning of chose hour (17:00EST by default).

daystartline.PNG


Download:
daystartline.lua
(2.36 KiB) Downloaded 2899 times


Code: Select all
function Init()
    indicator:name("Day Start Line");
    indicator:description("The indicator draws a vertical line at the specified time");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);

    indicator.parameters:addGroup("Parameters");
    indicator.parameters:addInteger("hour", "Hour (EST)", "Hour at start of which the line must be drawn", 17, 0, 23);
    indicator.parameters:addGroup("Style");
    indicator.parameters:addColor("clr", "Color", "", core.rgb(0, 127, 0));
    indicator.parameters:addInteger("width", "Width", "", 1, 1, 5);
    indicator.parameters:addInteger("style", "Style", "", core.LINE_DOT);
    indicator.parameters:setFlag("style", core.FLAG_LEVEL_STYLE);
end

local source;
local dummy, host;
local hour, clr, width, style;
local canwork, error;

function Prepare(onlyname)
    source = instance.source;
    clr = instance.parameters.clr;
    width = instance.parameters.width;
    style = instance.parameters.style;
    hour = instance.parameters.hour;
    host = core.host;

    local s, e = core.getcandle(source:barSize(), 0, host:execute("getTradingDayOffset"), 0);
    canwork = not(math.floor(e - s) >= 1);

    if not canwork then
        errtext = "The indicator must be applied on intraday charts";
        if onlyname then
            assert(false, errtext);
        else
            core.host:execute("setStatus", "error:" .. errtext);
        end
    end

    local name;
    name = profile:id() .. "(" .. source:name() .. "," .. hour .. ")";
    instance:name(name);

    if onlyname then
        return ;
    end


    dummy = instance:addStream("D", core.Line, name .. ".D", "D", clr, 0);
end

local last_s = nil;
local id = 0;

function Update(period, mode)
    if not canwork then
        return ;
    end

    -- calculation restarted
    if period == 0 then
        host:execute("removeAll");
        id = 0;
    end

    local s = source:serial(period);

    if last_s ~= nil and s == last_s then
        return ;
    end

    last_s = s;

    local date = source:date(period);
    local t = core.dateToTable(date);
    if t.min == 0 and t.hour == hour then
        id = id + 1;
        host:execute("drawLine", id, date, 0, date, 100000, clr, style, width, core.formatDate(host:execute("convertTime", core.TZ_EST, core.TZ_TS, date)));
    end
end
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1236
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Daystart vertical line

Postby mfoste1 » Mon Dec 12, 2011 4:53 pm

as borat would say...."Very Nice!"

thanks nikolay
mfoste1
 
Posts: 66
Joined: Thu Oct 21, 2010 6:55 pm

Re: Daystart vertical line

Postby nazaar » Mon Dec 12, 2011 5:23 pm

Brilliant, thank you!
nazaar
FXCodeBase: Initiate
 
Posts: 178
Joined: Fri May 27, 2011 2:21 pm
Location: Ontario, Canada

Re: Daystart vertical line

Postby nazaar » Thu Dec 15, 2011 1:27 pm

thank you again for making this simple yet very useful tool.

Is it possible, on the daily chart, add the option to place a vertical line on the 1st of each month?
nazaar
FXCodeBase: Initiate
 
Posts: 178
Joined: Fri May 27, 2011 2:21 pm
Location: Ontario, Canada

Re: Daystart vertical line

Postby santanae » Mon Dec 19, 2011 9:46 am

Love this Indicator thanks

I just started learning how to create (code) indicators and going through the docs and downloaded the tools to code.I wanted to ask you if there is away to create an indicator to just draw a horizontal line at exactly the close of each trading day (17:00 EST). I'm trying to work on something and I wanted to see if there was a way to do that.
Any assistance is apprecaited
santanae
 
Posts: 1
Joined: Mon Dec 19, 2011 9:28 am

Re: X bars back

Postby nazaar » Wed Jan 11, 2012 12:30 pm

Thanks again for the useful and very helpful indicator.

Taking the concept of this indicator I was wondering if you could create another indicator similar to it?

I am looking for an indicator that can count and indicate X bars back. For example, identify the 9th or 13th or 21st bar back. The identifying mark can be a vertical line running through the bar only (instead of a full vertical line) or an symbol place by above or below the X bar back.

thanks in advance.
nazaar
FXCodeBase: Initiate
 
Posts: 178
Joined: Fri May 27, 2011 2:21 pm
Location: Ontario, Canada

Re: Daystart vertical line

Postby Apprentice » Wed Jan 11, 2012 4:41 pm

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


Re: WEEK START LINE - vertical line

Postby nazaar » Tue Feb 28, 2012 1:18 pm

Hello,

The daystarline time divider has served very well on the lower time line charts but it produces to many lines to frequently on the higher time lines.

could you please add a new time divider indicator similar to the daystartline?

Please add a week start line tool. The weekly start would be Sunday 17:00 or 18:00.

thanks in advance.
nazaar
FXCodeBase: Initiate
 
Posts: 178
Joined: Fri May 27, 2011 2:21 pm
Location: Ontario, Canada

Re: Daystart vertical line

Postby Apprentice » Wed Feb 29, 2012 5:14 am

Your request is added to the development list.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 23962
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Custom Indicators

Who is online

Users browsing this forum: No registered users and 8 guests