PROBLEM WITH PROGRAMMING NEW INDICATORS FOR MARKETSCOPE USING LUA LANGUAGE
I would appreciate the assistance of anyone that can help me setup INTRADAY PIVOTS, SUPPORT (S1, S2) and RESISTANCE (R1, R2) in marketscope charting system using LUA Language.
The problem I’m having is that I could not find the code for DAILY TIME PERIODS in Marketscope and LUA. The default periods code is ‘bars’ i.e. 5minute, 1minute etc. Here is my code that I tried for the PIVOT INDICATOR:
function Init()
indicator:name(resources:get("name"));
indicator:description(resources:get("description") );
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator.parameters:addInteger("n", resources:get("param_n_name"), resources:get("param_n_description"), 0);
indicator.parameters:addColor("pp_color", resources:get("param_pp_color_name"), resources:get("param_pp_color_description"), core.rgb(255, 0, 0));
end
-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- TODO: Refine the first period calculation for each of the output streams.
-- TODO: Calculate all constants, create instances all subsequent indicators and load all required libraries
-- Parameters block
-- initialization of variables
local n;
local first;
local source = nil;
local rdg = 0;
-- Streams block
local pp = nil;
-- Routine
-- initialization of instance of indicator
function Prepare()
n = instance.parameters.n;
source = instance.source;
rdg = 0;
first = source:first();
local name = profile:id() .. "(" .. source:name() .. ", " .. n .. ")";
instance:name(name);
pp = instance:addStream("pp", core.Line, name, "pp", instance.parameters.pp_color, first);
end
-- Indicator calculation routine
-- TODO: Add your code for calculation output values
-- output will be seen on pp
function Update(period)
if period >= first and source:hasData(period) then
rdg = (source.high[period] + source.low[period] + source.close[period]) / 3;
pp[period] = rdg;
end
end
|