STARC Bands

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

STARC Bands

Postby TonyMod » Wed Jan 06, 2010 1:58 pm

Hello Everybody,

Here is the STARC Bands indicator that was developed by user's request. Original topic with the request: http://www.fxcodebase.com/code/viewtopic.php?f=18&t=159

Description on how to use this indicator you can find here:
http://www.investopedia.com/terms/s/starc.asp

Screenshot:
STARC Band.jpg
Screenshot from MarketScope.


Download:
STARC.lua
Download STARC Bands in .Lua
(2.69 KiB) Downloaded 818 times

Customizable STARC.lua
(5.95 KiB) Downloaded 118 times


Source:
Code: Select all
--- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
function Init()
    indicator:name("STARC Band");
    indicator:description("Indicates upper and lower limits of price movement.");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);
 
    indicator.parameters:addInteger("USM", "Multiplier", "The deviation multiplier", 2);
    indicator.parameters:addInteger("SMA_N", "Number of MVA periods", "The number of periods used in the Moving Average calculation", 6);
    indicator.parameters:addInteger("ATR_N", "Number of ATR periods", "The number of periods used in the Average True Range calculation", 14);
   
    indicator.parameters:addColor("UB_color", "Upper line color", "The color of the upper line", core.rgb(0, 255, 0));
    indicator.parameters:addColor("LB_color", "Lower line color", "The color of the lower line", core.rgb(255,0,0));
    indicator.parameters:addColor("AL_color", "Average line color", "The color of the average line", core.rgb(192,192,192));
end

-- Parameters block
local USM;

local first;
local source = nil;

-- internal indicators
local SMA = nil;
local ATR = nil;

-- Streams block
local UB = nil;
local LB = nil;
local AL = nil;

-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
function Prepare()
    USM = instance.parameters.USM;
    source = instance.source;   
    local SMA_N = instance.parameters.SMA_N;
    local ATR_N = instance.parameters.ATR_N;
    local PriceType = instance.parameters.SMA_source;
   
    local name = profile:id() .. "(" .. source:name() .. ", ".. USM .. ", ".. SMA_N .. ", ".. ATR_N .. ")";
    instance:name(name);   
   
    local pricestream = source.close;
   
    SMA = core.indicators:create("MVA", pricestream, SMA_N);
    ATR = core.indicators:create("ATR", source, ATR_N);
    first = math.max(SMA.DATA:first(), ATR.DATA:first());
    UB = instance:addStream("UB", core.Line, name, "Uppper Band", instance.parameters.UB_color, first);   
    LB = instance:addStream("LB", core.Line, name, "Lower Band", instance.parameters.LB_color, first);
    AL = instance:addStream("AL", core.Line, name, "Average", instance.parameters.AL_color, first);
end

-- Indicator calculation routine
-- TODO: Add your code for calculation output values
function Update(period, mode)
    SMA:update(mode);
    ATR:update(mode);

    if period >= first and source:hasData(period) then
        local smaVal = SMA.DATA[period];
        local atrVal = USM * ATR.DATA[period];

        UB[period] = smaVal + atrVal;
        LB[period] = smaVal - atrVal;
        AL[period] = smaVal;
    end
end


Respond to this topic if you have questions.
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: STARC Bands

Postby ausjus18 » Sun May 30, 2010 6:29 am

This is a really useful indicator. Is there a way of allowing multipliers that are 0.1 increments, not just limited to 1,2,3 etc. Thanks.
ausjus18
 
Posts: 4
Joined: Tue Apr 27, 2010 11:48 pm

Re: STARC Bands

Postby Nikolay.Gekht » Mon May 31, 2010 11:30 am

Yes, it is very easy. Only one line must be replaced
indicator.parameters:addInteger("USM", "Multiplier", "The deviation multiplier", 2);
with
indicator.parameters:addDouble("USM", "Multiplier", "The deviation multiplier", 2);

Download the modified version.
Nikolay.Gekht
FXCodeBase: Base Builder
 
Posts: 1222
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: STARC Bands

Postby ausjus18 » Tue Jun 01, 2010 8:14 pm

That's fantastic! Thank you Nikolay! Really appreciate your help.
Jürgen
ausjus18
 
Posts: 4
Joined: Tue Apr 27, 2010 11:48 pm

Re: STARC Bands

Postby Thecity » Sun Apr 26, 2015 4:02 pm

Hello, It would be nice to have the possibility to choose from differents type of the moving average (Ema for example).

The concept "MA + ATR*multiplier" it's really interesting, thank you.
Thecity
 
Posts: 6
Joined: Thu Apr 16, 2015 8:39 am

Re: STARC Bands

Postby Apprentice » Mon Apr 27, 2015 2:55 am

Customizable STARC.lua Added.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 17510
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: STARC Bands

Postby Apprentice » Sun Aug 13, 2017 5:53 am

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


Return to Custom Indicators

Who is online

Users browsing this forum: Yahoo [Bot] and 19 guests

cron