This indicator is described in this post:
http://fxcodebase.com/code/viewtopic.php?f=17&t=1974
The code is sourced at this earlier post here
http://74.52.98.35/code/viewtopic.php?f=17&t=940&sid=a4b312dd44113f005a0785088088828f
Q1 The variable session is declared as shown below. What do the curly brackets {} mean?
- Code: Select all
local session = {};
Q2 There follow various references to what are apparently properties of the variable.
for example session.id, session.labels, session.name, session.from etc and others. What data structure is this from? The first 10 lines of code show these assignments below:
- Code: Select all
function CreateSession(from, len, color, name, iname, labels)
local session = {};
local n;
session.id = gId;
gId = gId + 10;
session.labels = labels;
session.name = name;
session.from = from;
session.color = color;
session.len = len;
The full code for the function in question is below:
- Code: Select all
function CreateSession(from, len, color, name, iname, labels)
local session = {};
local n;
session.id = gId;
gId = gId + 10;
session.labels = labels;
session.name = name;
session.from = from;
session.color = color;
session.len = len;
n = name .. "_H";
session.high = instance:addStream(n, core.Line, iname .. "." .. n, name .. "H", color, local_first);
session.high:setStyle(instance.parameters.STYLE);
n = name .. "_L";
session.low = instance:addStream(n, core.Line, iname .. "." .. n, name .. "L", color, local_first);
session.low:setStyle(instance.parameters.STYLE);
session.highband = instance:addInternalStream(local_first, 0);
session.lowband = instance:addInternalStream(local_first, 0);
session.begin = instance:addInternalStream(0, 0);
instance:createChannelGroup(name, name, session.highband, session.lowband, color, 100 - instance.parameters.HL);
if labels and (S_H or S_OH or S_OD) and not(S_TT) then
session.LH = instance:createTextOutput("", name .. "_HL", "Arial", instance.parameters.FS, core.H_Right, core.V_Top, color, 0);
end
if labels and (S_L or S_OD) and not(S_TT) then
session.LL = instance:createTextOutput("", name .. "_LL", "Arial", instance.parameters.FS, core.H_Right, core.V_Bottom, color, 0);
end
if labels and S_N then
session.LN = instance:createTextOutput("", name .. "_LN", "Arial", instance.parameters.FS, core.H_Right, core.V_Top, color, 0);
end
return session;
end