nouvel indicateur ZigZag
Forums › ProRealTime forum Français › Support ProBuilder › nouvel indicateur ZigZag
- This topic has 24 replies, 2 voices, and was last updated 7 years ago by Nicolas.
-
-
05/11/2016 at 10:34 PM #6848
Cela devrait être cela et c’est du lourd.
function Init()
indicator:name(“ZigZag 9/1/9; 12/1/9; 18/1/18; 24/1/18; 36/1/36; 48/1/36; 72/1/72; 96/1/72; 144/1/144; 192/1/144”);
indicator:description(“”);
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);
indicator:setTag(“group”, “Swing”);indicator.parameters:addGroup(“ZigZag Style 9/1/9”);
indicator.parameters:addColor(“Zig_color1″,”Couleur pour la hausse”, “”, core.rgb(255, 128, 64));
indicator.parameters:addColor(“Zag_color1”, “Couleur pour la baisse”, “”, core.rgb(255, 128, 64));
indicator.parameters:addInteger(“widthZigZag1”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag1”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag1”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 12/1/9”);
indicator.parameters:addColor(“Zig_color2″,”Couleur pour la hausse”, “”, core.rgb(0, 255, 255));
indicator.parameters:addColor(“Zag_color2”, “Couleur pour la baisse”, “”, core.rgb(0, 255, 255));
indicator.parameters:addInteger(“widthZigZag2”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag2”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag2”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 18/1/18”);
indicator.parameters:addColor(“Zig_color3″,”Couleur pour la hausse”, “”, core.rgb(0, 128, 255));
indicator.parameters:addColor(“Zag_color3”, “Couleur pour la baisse”, “”, core.rgb(0, 128, 255));
indicator.parameters:addInteger(“widthZigZag3”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag3”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag3”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 24/1/18”);
indicator.parameters:addColor(“Zig_color4″,”Couleur pour la hausse”, “”, core.rgb(0, 128, 0));
indicator.parameters:addColor(“Zag_color4”, “Couleur pour la baisse”, “”, core.rgb(0, 128, 0));
indicator.parameters:addInteger(“widthZigZag4”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag4”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag4”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 36/1/36”);
indicator.parameters:addColor(“Zig_color5″,”Couleur pour la hausse”, “”, core.rgb(192, 192, 192));
indicator.parameters:addColor(“Zag_color5”, “Couleur pour la baisse”, “”, core.rgb(192, 192, 192));
indicator.parameters:addInteger(“widthZigZag5”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag5”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag5”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 48/1/36”);
indicator.parameters:addColor(“Zig_color6″,”Couleur pour la hausse”, “”, core.rgb(255, 0, 255));
indicator.parameters:addColor(“Zag_color6”, “Couleur pour la baisse”, “”, core.rgb(255, 0, 255));
indicator.parameters:addInteger(“widthZigZag6”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag6”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag6”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 72/1/72”);
indicator.parameters:addColor(“Zig_color7″,”Couleur pour la hausse”, “”, core.rgb(128, 128, 128));
indicator.parameters:addColor(“Zag_color7”, “Couleur pour la baisse”, “”, core.rgb(128, 128, 128));
indicator.parameters:addInteger(“widthZigZag7”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag7”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag7”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 96/1/72”);
indicator.parameters:addColor(“Zig_color8″,”Couleur pour la hausse”, “”, core.rgb(128, 64, 0));
indicator.parameters:addColor(“Zag_color8”, “Couleur pour la baisse”, “”, core.rgb(128, 64, 0));
indicator.parameters:addInteger(“widthZigZag8”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag8”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag8”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 144/1/144”);
indicator.parameters:addColor(“Zig_color9″,”Couleur pour la hausse”, “”, core.rgb(255, 0, 0));
indicator.parameters:addColor(“Zag_color9”, “Couleur pour la baisse”, “”, core.rgb(255, 0, 0));
indicator.parameters:addInteger(“widthZigZag9”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag9”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag9”, core.FLAG_LEVEL_STYLE);
indicator.parameters:addGroup(“ZigZag Style 192/1/144”);
indicator.parameters:addColor(“Zig_color10″,”Couleur pour la hausse”, “”, core.rgb(0, 0, 0));
indicator.parameters:addColor(“Zag_color10”, “Couleur pour la baisse”, “”, core.rgb(0, 0, 0));
indicator.parameters:addInteger(“widthZigZag10”, “Epaisseur ligne ZigZag”, “”, 1, 1, 5);
indicator.parameters:addInteger(“styleZigZag10”, “Style ligne ZigZag”, “”, core.LINE_SOLID);
indicator.parameters:setFlag(“styleZigZag10”, core.FLAG_LEVEL_STYLE);indicator.parameters:addGroup(“Affichage Label”);
indicator.parameters:addBoolean(“label”, “Montrer les Labels”, “”, true);
indicator.parameters:addInteger(“TextSize”, “Taille du texte”, “”, 10);
indicator.parameters:addDouble(“V_Shift”, “Décalage vertical du Label”, “”, 1.0);
indicator.parameters:addColor(“clr”, “Couleur du Label”, “”, core.rgb(127, 127, 127));
end— Streams block
local ZigC1; local ZigC2; local ZigC3; local ZigC4; local ZigC5; local ZigC6; local ZigC7; local ZigC8; local ZigC9; local ZigC10;
local ZagC1; local ZagC2; local ZagC3; local ZagC4; local ZagC5; local ZagC6; local ZagC7; local ZagC8; local ZagC9; local ZagC10;
local out1; local out2; local out3; local out4; local out5; local out6; local out7; local out8; local out9; local out10;
local first;
local source = nil;
local Pic;
local Trou;
local format;
local label;
local pipSize;
local V_Shift;
local LAST={};— Routine
function Prepare()
source = instance.source;
first = source:first();
label = instance.parameters.label;ZIGZAG1 = core.indicators:create(“ZIGZAG”, source, 9, 1, 9);
ZIGZAG2 = core.indicators:create(“ZIGZAG”, source, 12, 1, 9);
ZIGZAG3 = core.indicators:create(“ZIGZAG”, source, 18, 1, 18);
ZIGZAG4 = core.indicators:create(“ZIGZAG”, source, 24, 1, 18);
ZIGZAG5 = core.indicators:create(“ZIGZAG”, source, 36, 1, 36);
ZIGZAG6 = core.indicators:create(“ZIGZAG”, source, 48, 1, 36);
ZIGZAG7 = core.indicators:create(“ZIGZAG”, source, 72, 1, 72);
ZIGZAG8 = core.indicators:create(“ZIGZAG”, source, 96, 1, 72);
ZIGZAG9 = core.indicators:create(“ZIGZAG”, source, 144, 1, 144);
ZIGZAG10 = core.indicators:create(“ZIGZAG”, source, 192, 1, 144);local name = profile:id() .. “(” .. source:name() .. “)”;
instance:name(name);
out1 = instance:addStream(“out1”, core.Line, name, “9”, instance.parameters.Zig_color1, first);
out1:setWidth(instance.parameters.widthZigZag1);
out1:setStyle(instance.parameters.styleZigZag1);
ZigC1 = instance.parameters.Zig_color1;
ZagC1 = instance.parameters.Zag_color1;
out2 = instance:addStream(“out2”, core.Line, name, “12”, instance.parameters.Zig_color2, first);
out2:setWidth(instance.parameters.widthZigZag2);
out2:setStyle(instance.parameters.styleZigZag2);
ZigC2 = instance.parameters.Zig_color2;
ZagC2 = instance.parameters.Zag_color2;
out3 = instance:addStream(“out3”, core.Line, name, “18”, instance.parameters.Zig_color3, first);
out3:setWidth(instance.parameters.widthZigZag3);
out3:setStyle(instance.parameters.styleZigZag3);
ZigC3 = instance.parameters.Zig_color3;
ZagC3 = instance.parameters.Zag_color3;
out4 = instance:addStream(“out4”, core.Line, name, “24”, instance.parameters.Zig_color4, first);
out4:setWidth(instance.parameters.widthZigZag4);
out4:setStyle(instance.parameters.styleZigZag4);
ZigC4 = instance.parameters.Zig_color4;
ZagC4 = instance.parameters.Zag_color4;
out5 = instance:addStream(“out5”, core.Line, name, “36”, instance.parameters.Zig_color5, first);
out5:setWidth(instance.parameters.widthZigZag5);
out5:setStyle(instance.parameters.styleZigZag5);
ZigC5 = instance.parameters.Zig_color5;
ZagC5 = instance.parameters.Zag_color5;
out6 = instance:addStream(“out6”, core.Line, name, “48”, instance.parameters.Zig_color6, first);
out6:setWidth(instance.parameters.widthZigZag6);
out6:setStyle(instance.parameters.styleZigZag6);
ZigC6 = instance.parameters.Zig_color6;
ZagC6 = instance.parameters.Zag_color6;
out7 = instance:addStream(“out7”, core.Line, name, “72”, instance.parameters.Zig_color7, first);
out7:setWidth(instance.parameters.widthZigZag7);
out7:setStyle(instance.parameters.styleZigZag7);
ZigC7 = instance.parameters.Zig_color7;
ZagC7 = instance.parameters.Zag_color7;
out8 = instance:addStream(“out8”, core.Line, name, “96”, instance.parameters.Zig_color8, first);
out8:setWidth(instance.parameters.widthZigZag8);
out8:setStyle(instance.parameters.styleZigZag8);
ZigC8 = instance.parameters.Zig_color8;
ZagC8 = instance.parameters.Zag_color8;
out9 = instance:addStream(“out9”, core.Line, name, “144”, instance.parameters.Zig_color9, first);
out9:setWidth(instance.parameters.widthZigZag9);
out9:setStyle(instance.parameters.styleZigZag9);
ZigC9 = instance.parameters.Zig_color9;
ZagC9 = instance.parameters.Zag_color9;
out10 = instance:addStream(“out10”, core.Line, name, “192”, instance.parameters.Zig_color10, first);
out10:setWidth(instance.parameters.widthZigZag10);
out10:setStyle(instance.parameters.styleZigZag10);
ZigC10 = instance.parameters.Zig_color10;
ZagC10 = instance.parameters.Zag_color10;Pic = instance:createTextOutput(“Text”, “”, “Arial”, instance.parameters.TextSize, core.H_Center, core.V_Top, instance.parameters.clr, first);
Trou = instance:createTextOutput(“Text”, “”, “Arial”, instance.parameters.TextSize, core.H_Center, core.V_Bottom, instance.parameters.clr, first);
format = “%.” .. source:getPrecision() .. “f”;
pipSize=source:pipSize();
V_Shift = instance.parameters.V_Shift*pipSize;
end
function Update(period, mode)
if period < first then
return;
end
ZIGZAG1:update(mode); ZIGZAG2:update(mode); ZIGZAG3:update(mode); ZIGZAG4:update(mode); ZIGZAG5:update(mode); ZIGZAG6:update(mode); ZIGZAG7:update(mode); ZIGZAG8:update(mode); ZIGZAG9:update(mode); ZIGZAG10:update(mode);
if period < source:size()-1 then
return;
endlocal i;
for i = 1, period, 1 do
if i == 1 then
LAST[“HighTwo”] = nil;
LAST[“HighOne”] = nil;
LAST[“LowTwo”] = nil;
LAST[“LowOne”] = nil;
end
local PrevTrou = nil; local PrevPic = nil;
if ZIGZAG10.DATA[i] ~= 0 then
out10[i]= ZIGZAG10.DATA[i];
if isPeak192(i) then
out10:setColor(i, ZigC10);
elseif isTrough192(i) then
out10:setColor(i, ZagC10);
end
end
if ZIGZAG9.DATA[i] ~= 0 then
out9[i]= ZIGZAG9.DATA[i];
if isPeak144(i) then
out9:setColor(i, ZigC9);
elseif isTrough144(i) then
out9:setColor(i, ZagC9);
end
end
if ZIGZAG8.DATA[i] ~= 0 then
out8[i]= ZIGZAG8.DATA[i];
if isPeak96(i) then
out8:setColor(i, ZigC8);
elseif isTrough96(i) then
out8:setColor(i, ZagC8);
end
end
if ZIGZAG7.DATA[i] ~= 0 then
out7[i]= ZIGZAG7.DATA[i];
if isPeak72(i) then
out7:setColor(i, ZigC7);
elseif isTrough72(i) then
out7:setColor(i, ZagC7);
end
end
if ZIGZAG6.DATA[i] ~= 0 then
out6[i]= ZIGZAG6.DATA[i];
if isPeak48(i) then
out6:setColor(i, ZigC6);
elseif isTrough48(i) then
out6:setColor(i, ZagC6);
end
end
if ZIGZAG5.DATA[i] ~= 0 then
out5[i]= ZIGZAG5.DATA[i];
if isPeak36(i) then
out5:setColor(i, ZigC5);
elseif isTrough36(i) then
out5:setColor(i, ZagC5);
end
end
if ZIGZAG4.DATA[i] ~= 0 then
out4[i]= ZIGZAG4.DATA[i];
if isPeak24(i) then
out4:setColor(i, ZigC4);
elseif isTrough24(i) then
out4:setColor(i, ZagC4);
end
end
if ZIGZAG3.DATA[i] ~= 0 then
out3[i]= ZIGZAG3.DATA[i];
if isPeak18(i) then
out3:setColor(i, ZigC3);
elseif isTrough18(i) then
out3:setColor(i, ZagC3);
end
end
if ZIGZAG2.DATA[i] ~= 0 then
out2[i]= ZIGZAG2.DATA[i];
if isPeak12(i) then
out2:setColor(i, ZigC2);
elseif isTrough12(i) then
out2:setColor(i, ZagC2);
end
end
if ZIGZAG1.DATA[i] ~= 0 then
out1[i]= ZIGZAG1.DATA[i];
if isPeak9(i) then
out1:setColor(i, ZigC1);
elseif isTrough9(i) then
out1:setColor(i, ZagC1);
end
end
if label then
if isPeak192(i) then
if PrevTrou144(i) or PrevTrou96(i) or PrevTrou72(i) or PrevTrou48(i)
or PrevTrou36(i) or PrevTrou24(i) or PrevTrou18(i) or PrevTrou12(i) or PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\49\57\50”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\49\57\50”, string.format(format, source.high[i]));
end
elseif isTrough192(i) then
if PrevPic144(i) or PrevPic96(i) or PrevPic72(i) or PrevPic48(i)
or PrevPic36(i) or PrevPic24(i) or PrevPic18(i) or PrevPic12(i) or PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\49\57\50”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\49\57\50”, string.format(format, source.low[i]));
end
elseif isPeak144(i) then
if PrevTrou96(i) or PrevTrou72(i) or PrevTrou48(i) or PrevTrou36(i)
or PrevTrou24(i) or PrevTrou18(i) or PrevTrou12(i) or PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\49\52\52”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\49\52\52”, string.format(format, source.high[i]));
end
elseif isTrough144(i) then
if PrevPic96(i) or PrevPic72(i) or PrevPic48(i) or PrevPic36(i)
or PrevPic24(i) or PrevPic18(i) or PrevPic12(i) or PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\49\52\52”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\49\52\52”, string.format(format, source.low[i]));
end
elseif isPeak96(i) then
if PrevTrou72(i) or PrevTrou48(i) or PrevTrou36(i)
or PrevTrou24(i) or PrevTrou18(i) or PrevTrou12(i) or PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\57\54”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\57\54”, string.format(format, source.high[i]));
end
elseif isTrough96(i) then
if PrevPic72(i) or PrevPic48(i) or PrevPic36(i)
or PrevPic24(i) or PrevPic18(i) or PrevPic12(i) or PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\57\54”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\57\54”, string.format(format, source.low[i]));
end
elseif isPeak72(i) then
if PrevTrou48(i) or PrevTrou36(i) or PrevTrou24(i)
or PrevTrou18(i) or PrevTrou12(i) or PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\55\50”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\55\50”, string.format(format, source.high[i]));
end
elseif isTrough72(i) then
if PrevPic48(i) or PrevPic36(i) or PrevPic24(i)
or PrevPic18(i) or PrevPic12(i) or PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\55\50”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\55\50”, string.format(format, source.low[i]));
end
elseif isPeak48(i) then
if PrevTrou36(i) or PrevTrou24(i)
or PrevTrou18(i) or PrevTrou12(i) or PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\52\56”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\52\56”, string.format(format, source.high[i]));
end
elseif isTrough48(i) then
if PrevPic36(i) or PrevPic24(i)
or PrevPic18(i) or PrevPic12(i) or PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\52\56”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\52\56”, string.format(format, source.low[i]));
end
elseif isPeak36(i) then
if PrevTrou24(i) or PrevTrou18(i)
or PrevTrou12(i) or PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\51\54”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\51\54”, string.format(format, source.high[i]));
end
elseif isTrough36(i) then
if PrevPic24(i) or PrevPic18(i)
or PrevPic12(i) or PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\51\54”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\51\54”, string.format(format, source.low[i]));
end
elseif isPeak24(i) then
if PrevTrou18(i) or PrevTrou12(i) or PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\50\52”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\50\52”, string.format(format, source.high[i]));
end
elseif isTrough24(i) then
if PrevPic18(i) or PrevPic12(i) or PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\50\52”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\50\52”, string.format(format, source.low[i]));
end
elseif isPeak18(i) then
if PrevTrou12(i) or PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\49\56”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\49\56”, string.format(format, source.high[i]));
end
elseif isTrough18(i) then
if PrevPic12(i) or PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\49\56”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\49\56”, string.format(format, source.low[i]));
end
elseif isPeak12(i) then
if PrevTrou9(i) then
Pic:set(i, source.high[i]+V_Shift, “\72\80\49\50”, string.format(format, source.high[i]));
else
Pic:set(i, source.high[i]+V_Shift, “\90\90\49\50”, string.format(format, source.high[i]));
end
elseif isTrough12(i) then
if PrevPic9(i) then
Trou:set(i, source.low[i]-V_Shift, “\72\80\49\50”, string.format(format, source.low[i]));
else
Trou:set(i, source.low[i]-V_Shift, “\90\90\49\50”, string.format(format, source.low[i]));
end
elseif isPeak9(i) then
Pic:set(i, source.high[i]+V_Shift, “\90\90\57”, string.format(format, source.high[i]));
elseif isTrough9(i) then
Trou:set(i, source.low[i]-V_Shift, “\90\90\57”, string.format(format, source.low[i]));
end
if isPeak9(i) then
LAST[“HighTwo”]=LAST[“HighOne”]; LAST[“HighOne”]=i;
if LAST[“HighTwo”] ~= nil then
DeleteLabels(LAST[“LowOne”]+1, i-1);
end
elseif isTrough9(i) then
LAST[“LowTwo”]=LAST[“LowOne”]; LAST[“LowOne”]=i;
if LAST[“LowTwo”] ~= nil then
DeleteLabels(LAST[“HighOne”]+1, i-1);
end
end
end
end
end
function DeleteLabels(startBar, endBar)
local i;
for i=startBar,endBar,1 do
Pic:setNoData(i);
Trou:setNoData(i);
end
return;
end
—————————————————————————
function PrevTrou9(period)
local i;
for i = period, first, -1 do
if ZIGZAG2.DATA[i] ~= 0 and ZIGZAG2.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG2.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG1.DATA[i] ~= 0 and ZIGZAG1.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG1.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic9(period)
local i;
for i = period, first, -1 do
if ZIGZAG2.DATA[i] ~= 0 and ZIGZAG2.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG2.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG1.DATA[i] ~= 0 and ZIGZAG1.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG1.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou12(period)
local i;
for i = period, first, -1 do
if ZIGZAG3.DATA[i] ~= 0 and ZIGZAG3.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG3.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG2.DATA[i] ~= 0 and ZIGZAG2.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG2.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic12(period)
local i;
for i = period, first, -1 do
if ZIGZAG3.DATA[i] ~= 0 and ZIGZAG3.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG3.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG2.DATA[i] ~= 0 and ZIGZAG2.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG2.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou18(period)
local i;
for i = period, first, -1 do
if ZIGZAG4.DATA[i] ~= 0 and ZIGZAG4.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG4.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG3.DATA[i] ~= 0 and ZIGZAG3.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG3.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic18(period)
local i;
for i = period, first, -1 do
if ZIGZAG4.DATA[i] ~= 0 and ZIGZAG4.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG4.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG3.DATA[i] ~= 0 and ZIGZAG3.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG3.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou24(period)
local i;
for i = period, first, -1 do
if ZIGZAG5.DATA[i] ~= 0 and ZIGZAG5.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG5.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG4.DATA[i] ~= 0 and ZIGZAG4.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG4.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic24(period)
local i;
for i = period, first, -1 do
if ZIGZAG5.DATA[i] ~= 0 and ZIGZAG5.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG5.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG4.DATA[i] ~= 0 and ZIGZAG4.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG4.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou36(period)
local i;
for i = period, first, -1 do
if ZIGZAG6.DATA[i] ~= 0 and ZIGZAG6.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG6.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG5.DATA[i] ~= 0 and ZIGZAG5.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG5.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic36(period)
local i;
for i = period, first, -1 do
if ZIGZAG6.DATA[i] ~= 0 and ZIGZAG6.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG6.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG5.DATA[i] ~= 0 and ZIGZAG5.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG5.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou48(period)
local i;
for i = period, first, -1 do
if ZIGZAG7.DATA[i] ~= 0 and ZIGZAG7.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG7.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG6.DATA[i] ~= 0 and ZIGZAG6.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG6.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic48(period)
local i;
for i = period, first, -1 do
if ZIGZAG7.DATA[i] ~= 0 and ZIGZAG7.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG7.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG6.DATA[i] ~= 0 and ZIGZAG6.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG6.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou72(period)
local i;
for i = period, first, -1 do
if ZIGZAG8.DATA[i] ~= 0 and ZIGZAG8.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG8.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG7.DATA[i] ~= 0 and ZIGZAG7.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG7.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic72(period)
local i;
for i = period, first, -1 do
if ZIGZAG8.DATA[i] ~= 0 and ZIGZAG8.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG8.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG7.DATA[i] ~= 0 and ZIGZAG7.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG7.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou96(period)
local i;
for i = period, first, -1 do
if ZIGZAG9.DATA[i] ~= 0 and ZIGZAG9.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG9.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG8.DATA[i] ~= 0 and ZIGZAG8.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG8.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic96(period)
local i;
for i = period, first, -1 do
if ZIGZAG9.DATA[i] ~= 0 and ZIGZAG9.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG9.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG8.DATA[i] ~= 0 and ZIGZAG8.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG8.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou144(period)
local i;
for i = period, first, -1 do
if ZIGZAG10.DATA[i] ~= 0 and ZIGZAG10.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG10.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG9.DATA[i] ~= 0 and ZIGZAG9.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG9.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic144(period)
local i;
for i = period, first, -1 do
if ZIGZAG10.DATA[i] ~= 0 and ZIGZAG10.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG10.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG9.DATA[i] ~= 0 and ZIGZAG9.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG9.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevTrou192(period)
local i;
for i = period, first, -1 do
if ZIGZAG1.DATA[i] ~= 0 and ZIGZAG10.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG10.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG10.DATA[i] ~= 0 and ZIGZAG10.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG10.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
function PrevPic192(period)
local i;
for i = period, first, -1 do
if ZIGZAG1.DATA[i] ~= 0 and ZIGZAG10.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG10.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return false;
elseif ZIGZAG10.DATA[i] ~= 0 and ZIGZAG10.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG10.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
end
end
return false;
end
—————————————————————————
function isPeak9(period)
local i;
for i = period, first, -1 do
if ZIGZAG1.DATA[i] ~= 0
and ZIGZAG1.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG1.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak12(period)
local i;
for i = period, first, -1 do
if ZIGZAG2.DATA[i] ~= 0
and ZIGZAG2.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG2.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak18(period)
local i;
for i = period, first, -1 do
if ZIGZAG3.DATA[i] ~= 0
and ZIGZAG3.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG3.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak24(period)
local i;
for i = period, first, -1 do
if ZIGZAG4.DATA[i] ~= 0
and ZIGZAG4.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG4.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak36(period)
local i;
for i = period, first, -1 do
if ZIGZAG5.DATA[i] ~= 0
and ZIGZAG5.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG5.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak48(period)
local i;
for i = period, first, -1 do
if ZIGZAG6.DATA[i] ~= 0
and ZIGZAG6.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG6.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak72(period)
local i;
for i = period, first, -1 do
if ZIGZAG7.DATA[i] ~= 0
and ZIGZAG7.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG7.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak96(period)
local i;
for i = period, first, -1 do
if ZIGZAG8.DATA[i] ~= 0
and ZIGZAG8.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG8.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak144(period)
local i;
for i = period, first, -1 do
if ZIGZAG9.DATA[i] ~= 0
and ZIGZAG9.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG9.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isPeak192(period)
local i;
for i = period, first, -1 do
if ZIGZAG10.DATA[i] ~= 0
and ZIGZAG10.DATA[i] > source.high[i] – source:pipSize() *0.001 and ZIGZAG10.DATA[i] < source.high[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
—————————————————————————-
function isTrough9(period)
local i;
for i = period, first, -1 do
if ZIGZAG1.DATA[i] ~= 0
and ZIGZAG1.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG1.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isTrough12(period)
local i;
for i = period, first, -1 do
if ZIGZAG2.DATA[i] ~= 0
and ZIGZAG2.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG2.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
endfunction isTrough18(period)
local i;
for i = period, first, -1 do
if ZIGZAG3.DATA[i] ~= 0
and ZIGZAG3.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG3.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isTrough24(period)
local i;
for i = period, first, -1 do
if ZIGZAG4.DATA[i] ~= 0
and ZIGZAG4.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG4.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isTrough36(period)
local i;
for i = period, first, -1 do
if ZIGZAG5.DATA[i] ~= 0
and ZIGZAG5.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG5.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isTrough48(period)
local i;
for i = period, first, -1 do
if ZIGZAG6.DATA[i] ~= 0
and ZIGZAG6.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG6.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isTrough72(period)
local i;
for i = period, first, -1 do
if ZIGZAG7.DATA[i] ~= 0
and ZIGZAG7.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG7.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isTrough96(period)
local i;
for i = period, first, -1 do
if ZIGZAG8.DATA[i] ~= 0
and ZIGZAG8.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG8.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isTrough144(period)
local i;
for i = period, first, -1 do
if ZIGZAG9.DATA[i] ~= 0
and ZIGZAG9.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG9.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
function isTrough192(period)
local i;
for i = period, first, -1 do
if ZIGZAG10.DATA[i] ~= 0
and ZIGZAG10.DATA[i] > source.low[i] – source:pipSize() *0.001 and ZIGZAG10.DATA[i] < source.low[i] + source:pipSize() *0.001 then
return true;
else
return false;
end
end
return false;
end
—————————————————————————07/14/2016 at 10:02 AM #1045707/14/2016 at 10:45 AM #10459Non désolé pour ta version TS2, c’est un peu lourd et on est contraint par les lookback pour retracer les derniers zigzag, ce qui n’est pas possible sous PRT, car l’historique n’est lu qu’une seule fois et on ne peut effacer les informations déjà tracées.
Sinon j’ai fait ça récemment :
1234567891011121314151617181920212223242526272829303132InpDepth=7 // DepthInpDeviation=5 // Deviation//InpBackstep=3 // Backstepif barindex>InpDepth then//main loopfor i = 0 to InpDepth do//--- find lowest low in depth of barsextremum=lowest[InpDepth](low)[1]//--- this lowest has been found previouslyif(extremum=lastlow) thenextremum=0//extremum[1]//0.0else//--- new last lowlastlow=extremum//--- discard extremum if current low is too highif(low[0]-extremum>InpDeviation*Pipsize) thenextremum=0//extremum[1]//0.0endifendif//--- found extremum is current lowif(low[i]=extremum) thenif(low[0]=extremum) then //and i>=InpBackstep) thenExtLowBuffer=extremumelseExtLowBuffer=ExtLowBuffer[1]//0.0endifendifnextendifRETURN ExtLowBuffer coloured(210,0,0) as "low zigzag"C’est une tentative pour recoder le zigzag de MT4 sous PRT, mais je n’en suis pas satisfait.. il n’y a que les “low zigzag” dans cette version… A voir..
01/17/2017 at 1:18 PM #21444Bonjour Nicolas et meilleurs vœux pour la nouvelle année. Je reviens vers toi pour une nouvelle demande. Le HP-ZZ d’Eurasien sous TS2 est très lourd et pour un utilisateur habitué comme moi inutile. Lors de l’une des ses premières versions il avait le ” ZZ NOHP ” qui n’indique pas toutes ces indications inutiles : HP 192/26 où pic, bas et niveaux. Bref il n’indique que les lignes des ZZ qui sont toujours sur les + hauts/bas selon les ZZ entrées dans la plateforme.
Et j’ai justement cet indicateur sous MT4. Il y a-t’il une chance de le coder pour PRT. Merci. Denis.
01/17/2017 at 7:05 PM #2150301/18/2017 at 11:20 AM #21544Bonjour Nicolas. Voici le texte copié dans Meta Editor. C’est le ZZ avec les règlages 9-1-9 et la liste des autres ZZ est : 12-1-9 18-1-18 24-1-18 36-1-36 48-1-36 72-1-72 96-1-72 144-1-144 et 192-1-144. Ces ZZ sont entrés du plus petit au plus grand dans MT4. Ils m’avaient été donnés par Popoke que tu connais, je veux dire Fernand Rodrigues. Merci d’avance.
//+——————————————————————+
//| Custom Moving Average.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+——————————————————————+
#property copyright “Copyright © 2005, MetaQuotes Software Corp.”
#property link “http://www.metaquotes.net/”#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 MediumSeaGreen
//—- indicator parameters
extern int ExtDepth=9;
extern int ExtDeviation=1;
extern int ExtBackstep=9;
//—- indicator buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];//+——————————————————————+
//| Custom indicator initialization function |
//+——————————————————————+
int init()
{
IndicatorBuffers(2);
//—- drawing settings
SetIndexStyle(0,DRAW_SECTION);
//—- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(0,0.0);
ArraySetAsSeries(ExtMapBuffer,true);
ArraySetAsSeries(ExtMapBuffer2,true);
//—- indicator short name
IndicatorShortName(“ZigZagFirstBar(“+ExtDepth+”,”+ExtDeviation+”,”+ExtBackstep+”)”);
//—- initialization done
return(0);
}
//+——————————————————————+
//| |
//+——————————————————————+
int start()
{
int shift, back,lasthighpos,lastlowpos;
double val,res;
double curlow,curhigh,lasthigh,lastlow;for(shift=Bars-ExtDepth; shift>=0; shift–)
{
val=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,shift)];
if(val==lastlow) val=0.0;
else
{
lastlow=val;
if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer[shift+back];
if((res!=0)&&(res>val)) continue;//ExtMapBuffer[shift+back]=0.0;
}
}
}
ExtMapBuffer[shift]=val;
//— high
val=High[Highest(NULL,0,MODE_HIGH,ExtDepth,shift)];
if(val==lasthigh) val=0.0;
else
{
lasthigh=val;
if((val-High[shift])>(ExtDeviation*Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer2[shift+back];
if((res!=0)&&(res<val)) continue;//ExtMapBuffer2[shift+back]=0.0;
}
}
}
ExtMapBuffer2[shift]=val;
}// final cutting
lasthigh=-1; lasthighpos=-1;
lastlow=-1; lastlowpos=-1;for(shift=Bars-ExtDepth; shift>=0; shift–)
{
curlow=ExtMapBuffer[shift];
curhigh=ExtMapBuffer2[shift];
// if((curlow==0.0)||(curhigh==0.0)) continue;
//—
if(curhigh!=0)
{
if(lasthigh>0)
{
if(lasthigh<curhigh) ExtMapBuffer2[lasthighpos]=0;
else ExtMapBuffer2[shift]=0;
}//ÿ
//—
if(lasthigh<curhigh || lasthigh<0)
{
lasthigh=curhigh;
lasthighpos=shift;
}// ÿ
lastlow=-1;
}//ÿ
//—-
if(curlow!=0)
{
if(lastlow>0)
{
if(lastlow>curlow) ExtMapBuffer[lastlowpos]=0;
else ExtMapBuffer[shift]=0;
}//z
//—
if((curlow<lastlow)||(lastlow<0))
{
lastlow=curlow;
lastlowpos=shift;
}//z
lasthigh=-1;
}//
}for(shift=Bars-1; shift>=0; shift–)
{
if(shift>=Bars-ExtDepth) ExtMapBuffer[shift]=0.0;
else
{
res=ExtMapBuffer2[shift];
if(res!=0.0) ExtMapBuffer[shift]=res;
//if(res>0.0) ExtMapBuffer[shift]=res;
}
}
}02/03/2017 at 11:11 AM #2375602/03/2017 at 11:29 AM #2376005/25/2017 at 7:10 PM #36650Bonjour Nicolas. Je me permets de revenir vers toi. Je ne savais pas trop comment joindre le fichier mq4. Voilà j’ai fait un clic droit sur le fichier dans le navigateur de MT4 et ouvert celuyi’ci dans ” create editor ” et j’ai ceci :
//+——————————————————————+
//| Custom Moving Average.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+——————————————————————+
#property copyright “Copyright © 2005, MetaQuotes Software Corp.”
#property link “http://www.metaquotes.net/”#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 MediumSeaGreen
//—- indicator parameters
extern int ExtDepth=9;
extern int ExtDeviation=1;
extern int ExtBackstep=9;
//—- indicator buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];//+——————————————————————+
//| Custom indicator initialization function |
//+——————————————————————+
int init()
{
IndicatorBuffers(2);
//—- drawing settings
SetIndexStyle(0,DRAW_SECTION);
//—- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(0,0.0);
ArraySetAsSeries(ExtMapBuffer,true);
ArraySetAsSeries(ExtMapBuffer2,true);
//—- indicator short name
IndicatorShortName(“ZigZagFirstBar(“+ExtDepth+”,”+ExtDeviation+”,”+ExtBackstep+”)”);
//—- initialization done
return(0);
}
//+——————————————————————+
//| |
//+——————————————————————+
int start()
{
int shift, back,lasthighpos,lastlowpos;
double val,res;
double curlow,curhigh,lasthigh,lastlow;for(shift=Bars-ExtDepth; shift>=0; shift–)
{
val=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,shift)];
if(val==lastlow) val=0.0;
else
{
lastlow=val;
if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer[shift+back];
if((res!=0)&&(res>val)) continue;//ExtMapBuffer[shift+back]=0.0;
}
}
}
ExtMapBuffer[shift]=val;
//— high
val=High[Highest(NULL,0,MODE_HIGH,ExtDepth,shift)];
if(val==lasthigh) val=0.0;
else
{
lasthigh=val;
if((val-High[shift])>(ExtDeviation*Point)) val=0.0;
else
{
for(back=1; back<=ExtBackstep; back++)
{
res=ExtMapBuffer2[shift+back];
if((res!=0)&&(res<val)) continue;//ExtMapBuffer2[shift+back]=0.0;
}
}
}
ExtMapBuffer2[shift]=val;
}// final cutting
lasthigh=-1; lasthighpos=-1;
lastlow=-1; lastlowpos=-1;for(shift=Bars-ExtDepth; shift>=0; shift–)
{
curlow=ExtMapBuffer[shift];
curhigh=ExtMapBuffer2[shift];
// if((curlow==0.0)||(curhigh==0.0)) continue;
//—
if(curhigh!=0)
{
if(lasthigh>0)
{
if(lasthigh<curhigh) ExtMapBuffer2[lasthighpos]=0;
else ExtMapBuffer2[shift]=0;
}//ÿ
//—
if(lasthigh<curhigh || lasthigh<0)
{
lasthigh=curhigh;
lasthighpos=shift;
}// ÿ
lastlow=-1;
}//ÿ
//—-
if(curlow!=0)
{
if(lastlow>0)
{
if(lastlow>curlow) ExtMapBuffer[lastlowpos]=0;
else ExtMapBuffer[shift]=0;
}//z
//—
if((curlow<lastlow)||(lastlow<0))
{
lastlow=curlow;
lastlowpos=shift;
}//z
lasthigh=-1;
}//
}for(shift=Bars-1; shift>=0; shift–)
{
if(shift>=Bars-ExtDepth) ExtMapBuffer[shift]=0.0;
else
{
res=ExtMapBuffer2[shift];
if(res!=0.0) ExtMapBuffer[shift]=res;
//if(res>0.0) ExtMapBuffer[shift]=res;
}
}
}alors si cela pourrait t’être utile j’en serai ravi. D’avance merci. Denis.
05/25/2017 at 7:19 PM #36651Malheureusement non, le problème reste entier avec ce type de code issu de MT4 : il retrace ce qui est déjà tracé. J’ai reçu par email un code de zigzag pouvant éventuellement convenir il y a quelques temps, je vais le partager (j’espère ne pas oublier car je ne peux pas le faire tout de suite, il faudra me le rappeler sinon 😉 ).
Sinon, j’ai prévu dans la prochaine formation de programmation prorealtime à venir, la reprogrammation complète d’un indicateur zigzag personnel.
-
AuthorPosts
Find exclusive trading pro-tools on