Bonjour à toutes et à tous.
Quelqu'un pourrait-il svp m'aider ?
Vous trouverez ce dessous le script de l'indicateur Mindhero destiné à la Station Marketscope de FXCM (indicateur au fichier "lua").
Une âme charitable pourait-il me créée à l'identique cet indicateur pour MT4 ?
Un énorme merci d'avance.
-- -----------------------------------------------------------
-- the port of the mindhero MT4 indicator to lua
-- the original indicator:
-- codebase.mql4.com/4065 via Scriptor
-- "Mindherostar Inc." / superhero
-- "www.mindrends.com"
-- -----------------------------------------------------------
function Init()
indicator:name("Mindhero");
indicator:description("");
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator.parameters:addInteger("artp", "Number of periods to calculate H/L TR", "", 7);
indicator.parameters:addDouble("cecf", "Coefficient for applying H/L TR", "", 0.7);
indicator.parameters:addInteger("atrn", "ATR periods", "", 10);
indicator.parameters:addBoolean("signal", "Signal Mode", "The parameter is used by the mindhero signal. do not change it!", false);
indicator.parameters:addColor("clrUP", "Up Arrow", "", core.rgb(255, 0, 0));
indicator.parameters:addColor("clrDN", "Down Arow", "", core.rgb(0, 0, 255));
end
local source;
local bid, ask;
local up, down;
local signalout;
local artp = 7;
local atrn = 10;
local cecf = 0.7;
local signal;
local river;
local emaxtra;
local p;
local tr;
local ATR;
local first;
function Prepare()
artp = instance.parameters.artp;
atrn = instance.parameters.atrn;
cecf = instance.parameters.cecf;
signal = instance.parameters.signal;
bid = core.host:execute("getBidPrice");
ask = core.host:execute("getAskPrice");
source = instance.source;
local name = profile:id() .. ":'(" .. artp .. "," .. cecf .. "," .. atrn .. ")";
instance:name(name);
ATR = core.indicators:create("ATR", source, atrn);
first = math.max(ATR.DATA:first(), source:first() + artp + 1, source:first() + 3);
up = instance:createTextOutput ("Up", "Up", "Wingdings", 10, core.H_Center, core.V_Top, instance.parameters.clrUP, 0);
down = instance:createTextOutput ("Dn", "Dn", "Wingdings", 10, core.H_Center, core.V_Bottom, instance.parameters.clrDN, 0);
if signal then
signalout = instance:addStream("S", core.Line, name .. ".S", "S", core.rgb(0, 0, 0), 0);
end
river = instance:addInternalStream(0, 0);
emaxtra = instance:addInternalStream(0, 0);
p = instance:addInternalStream(0, 0);
tr = instance:addInternalStream(0, 0);
end
function Update(period, mode)
ATR:update(mode);
if period > first then
local spread, ctr, i, atr, weight, widcha;
local criver, cemaxtra, range1, cp, cr1;
spread = math.abs(bid.median[period] - ask.median[period]);
ctr = spread + source.high[period] - source.low[period];
if math.abs(spread + source.high[period] - source.close[period - 1]) > ctr then
ctr = math.abs(spread + source.high[period] - source.close[period - 1]);
end
if math.abs(source.low[period] - source.close[period - 1]) > ctr then
ctr = math.abs(source.low[period] - source.close[period - 1]);
end
tr[period] = ctr;
atr = 0;
weight = artp;
for i = 0, artp - 1, 1 do
atr = atr + tr[period - i] * weight;
weight = weight - 1;
end
atr = 2.0 * atr / (artp * (artp + 1));
widcha = cecf * atr;
criver = river[period - 1];
cemaxtra = emaxtra[period - 1];
if criver == 1 and (source.low[period] < (cemaxtra - widcha)) then
criver = 0;
cemaxtra = spread + source.high[period];
end
if criver == 0 and ((spread + source.high[period]) > (cemaxtra + widcha)) then
criver = 1;
cemaxtra = source.low[period];
end
if criver == 1 and source.low[period] > cemaxtra then
cemaxtra = source.low[period];
end
if criver == 0 and ((spread + source.high[period]) < cemaxtra) then
cemaxtra = spread + source.high[period];
end
cp = p[period - 1];
range1 = ATR.DATA[period];
if criver == 1 then
if cp ~= 1 then
cr1 = source.low[period] - range1 * 2.0 / 3.0;
else
cr1 = 0;
end
if cr1 ~= 0 then
down:set(period, cr1, "\225");
if signal then
signalout[period] = -cr1;
end
end
cp = 1;
else
if cp ~= 2 then
cr1 = spread + source.high[period] + range1 * 2.0 / 3.0;
else
cr1 = 0;
end
if cr1 ~= 0 then
up:set(period, cr1, "\226");
if signal then
signalout[period] = cr1;
end
end
cp = 2;
end
p[period] = cp;
river[period] = criver;
emaxtra[period] = cemaxtra;
elseif period > source:first() + 1 then
local spread, ctr;
spread = math.abs(bid.median[period] - ask.median[period]);
ctr = spread + source.high[period] - source.low[period];
if math.abs(spread + source.high[period] - source.close[period - 1]) > ctr then
ctr = math.abs(spread + source.high[period] - source.close[period - 1]);
end
if math.abs(source.low[period] - source.close[period - 1]) > ctr then
ctr = math.abs(source.low[period] - source.close[period - 1]);
end
tr[period] = ctr;
if period == first then
emaxtra[period] = source.close[period - 1];
p[period] = 0;
if source.close[period - 1] > source.close[period - 2] then
river[period] = 1;
else
river[period] = 0;
end
end
end
end
Quelqu'un pourrait-il svp m'aider ?
Vous trouverez ce dessous le script de l'indicateur Mindhero destiné à la Station Marketscope de FXCM (indicateur au fichier "lua").
Une âme charitable pourait-il me créée à l'identique cet indicateur pour MT4 ?
Un énorme merci d'avance.
-- -----------------------------------------------------------
-- the port of the mindhero MT4 indicator to lua
-- the original indicator:
-- codebase.mql4.com/4065 via Scriptor
-- "Mindherostar Inc." / superhero
-- "www.mindrends.com"
-- -----------------------------------------------------------
function Init()
indicator:name("Mindhero");
indicator:description("");
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator.parameters:addInteger("artp", "Number of periods to calculate H/L TR", "", 7);
indicator.parameters:addDouble("cecf", "Coefficient for applying H/L TR", "", 0.7);
indicator.parameters:addInteger("atrn", "ATR periods", "", 10);
indicator.parameters:addBoolean("signal", "Signal Mode", "The parameter is used by the mindhero signal. do not change it!", false);
indicator.parameters:addColor("clrUP", "Up Arrow", "", core.rgb(255, 0, 0));
indicator.parameters:addColor("clrDN", "Down Arow", "", core.rgb(0, 0, 255));
end
local source;
local bid, ask;
local up, down;
local signalout;
local artp = 7;
local atrn = 10;
local cecf = 0.7;
local signal;
local river;
local emaxtra;
local p;
local tr;
local ATR;
local first;
function Prepare()
artp = instance.parameters.artp;
atrn = instance.parameters.atrn;
cecf = instance.parameters.cecf;
signal = instance.parameters.signal;
bid = core.host:execute("getBidPrice");
ask = core.host:execute("getAskPrice");
source = instance.source;
local name = profile:id() .. ":'(" .. artp .. "," .. cecf .. "," .. atrn .. ")";
instance:name(name);
ATR = core.indicators:create("ATR", source, atrn);
first = math.max(ATR.DATA:first(), source:first() + artp + 1, source:first() + 3);
up = instance:createTextOutput ("Up", "Up", "Wingdings", 10, core.H_Center, core.V_Top, instance.parameters.clrUP, 0);
down = instance:createTextOutput ("Dn", "Dn", "Wingdings", 10, core.H_Center, core.V_Bottom, instance.parameters.clrDN, 0);
if signal then
signalout = instance:addStream("S", core.Line, name .. ".S", "S", core.rgb(0, 0, 0), 0);
end
river = instance:addInternalStream(0, 0);
emaxtra = instance:addInternalStream(0, 0);
p = instance:addInternalStream(0, 0);
tr = instance:addInternalStream(0, 0);
end
function Update(period, mode)
ATR:update(mode);
if period > first then
local spread, ctr, i, atr, weight, widcha;
local criver, cemaxtra, range1, cp, cr1;
spread = math.abs(bid.median[period] - ask.median[period]);
ctr = spread + source.high[period] - source.low[period];
if math.abs(spread + source.high[period] - source.close[period - 1]) > ctr then
ctr = math.abs(spread + source.high[period] - source.close[period - 1]);
end
if math.abs(source.low[period] - source.close[period - 1]) > ctr then
ctr = math.abs(source.low[period] - source.close[period - 1]);
end
tr[period] = ctr;
atr = 0;
weight = artp;
for i = 0, artp - 1, 1 do
atr = atr + tr[period - i] * weight;
weight = weight - 1;
end
atr = 2.0 * atr / (artp * (artp + 1));
widcha = cecf * atr;
criver = river[period - 1];
cemaxtra = emaxtra[period - 1];
if criver == 1 and (source.low[period] < (cemaxtra - widcha)) then
criver = 0;
cemaxtra = spread + source.high[period];
end
if criver == 0 and ((spread + source.high[period]) > (cemaxtra + widcha)) then
criver = 1;
cemaxtra = source.low[period];
end
if criver == 1 and source.low[period] > cemaxtra then
cemaxtra = source.low[period];
end
if criver == 0 and ((spread + source.high[period]) < cemaxtra) then
cemaxtra = spread + source.high[period];
end
cp = p[period - 1];
range1 = ATR.DATA[period];
if criver == 1 then
if cp ~= 1 then
cr1 = source.low[period] - range1 * 2.0 / 3.0;
else
cr1 = 0;
end
if cr1 ~= 0 then
down:set(period, cr1, "\225");
if signal then
signalout[period] = -cr1;
end
end
cp = 1;
else
if cp ~= 2 then
cr1 = spread + source.high[period] + range1 * 2.0 / 3.0;
else
cr1 = 0;
end
if cr1 ~= 0 then
up:set(period, cr1, "\226");
if signal then
signalout[period] = cr1;
end
end
cp = 2;
end
p[period] = cp;
river[period] = criver;
emaxtra[period] = cemaxtra;
elseif period > source:first() + 1 then
local spread, ctr;
spread = math.abs(bid.median[period] - ask.median[period]);
ctr = spread + source.high[period] - source.low[period];
if math.abs(spread + source.high[period] - source.close[period - 1]) > ctr then
ctr = math.abs(spread + source.high[period] - source.close[period - 1]);
end
if math.abs(source.low[period] - source.close[period - 1]) > ctr then
ctr = math.abs(source.low[period] - source.close[period - 1]);
end
tr[period] = ctr;
if period == first then
emaxtra[period] = source.close[period - 1];
p[period] = 0;
if source.close[period - 1] > source.close[period - 2] then
river[period] = 1;
else
river[period] = 0;
end
end
end
end