Не дайте пропасть двум хорошим индикаторам sos sos sos HELP HELP

 
Пока жив Mt3 - не дайте пропасть индикаторам

1 - первый
/*[[
	Name := FLOAT
	Author := Bigblockfw
	Separate Window := Yes
	First Color := RoyalBlue
	First Draw Type := histogram
	First Symbol := 217
	Use Second Data := Yes
	Second Color := Black
	Second Draw Type := Line
	Second Symbol := 218
]]*/
input    : float(200),use_fibos(1),Backtesting(0);
Variable : 
shift(0),f(0),c1(0),high_bar(0),Low_bar(0),bars_high(0),bars_low(0);
Variable : 
cumulativeV(0),FLOATV(0),cumulativeV2(0),loopbegin2(0),swing(0),swing_time(0);
Variable : swingv(0),loopbegin1(0),cnt(0);
Variable : first(True),first1(True), prevbars(0);
Variable : cvstart(0),cvend(0),bar(0),newcv(0),CV(0),CV2(0);
Variable : fib23(0),fib38(0),fib50(0),fib62(0),fib76(0);
Variable : dinap0(0),dinap1(0),dinap2(0),dinap3(0),dinap4(0),dinap5(0);
Variable : CVL(0),CVL1(0),CVL2(0),CVL3(0),CVL4(0);

cumulativeV=0;
cumulativeV2=0;

SetLoopCount(0);
If Bars < prevbars Or Bars-prevbars>1 Then
first = True;
first1 = True;
prevbars = Bars;
FLOATV=0;

If first Then Begin
	loopbegin1 = Bars-float-1;
	loopbegin2 = Bars-float-1;
	first = False;

loopbegin1 = loopbegin1+1;
For shift = loopbegin1 Downto 0 Begin
//find high and low
high_bar = H[Highest(MODE_HIGH,float,float)];
Low_bar = L[Lowest(MODE_LOW,float,float)];
//find bar counts
bars_high = highest(MODE_HIGH,float,float);
bars_low = lowest(MODE_LOW,float,float);
//find swing price differance
swing = H[Highest(MODE_HIGH,float,float)]- 
L[Lowest(MODE_LOW,float,float)];
//find float time barcount
swing_time = abs(bars_low-bars_high);

//find cumulative volume for float period
IF bars_high < bars_low then
{
cvstart=bars_low;
cvend=bars_high;
}
else
{
cvstart=bars_high;
cvend=bars_low;
}
If first1 and FLOATV=0 Then Begin
for shift = cvstart downto cvend Begin {
FLOATV=FLOATV+V[shift];
first1 = False;}
end;

//find cumulative volume since last turnover
for shift = cvstart downto 0 Begin
cumulativeV=cumulativeV+V[shift];

if cumulativeV>=FLOATV then{
cumulativeV=0;
}

SetIndexValue(shift,cumulativeV*0.001);//RoyalBlue
SetIndexValue2(shift,FLOATV*0.001);//black

comment(
"\n","high was   ",bars_high,"  bars ago",
"\n","Low was    ",bars_low," bars ago","\n",
"\n","Float time was  =      ", swing_time," bars",
"\n","Float Vol. left    =     ",FLOATV-cumulativeV,
"\n","Float Volume    =     ",FLOATV
);

MoveObject("swingtop",OBJ_TRENDLINE,Time[cvstart],high_bar,Time[1],high_bar,RoyalBlue,4,STYLE_SOLID);
MoveObject("swingbottom",OBJ_TRENDLINE,Time[cvstart],Low_bar,Time[1],Low_bar,RoyalBlue,4,STYLE_SOLID);

//fibos
If use_fibos=1 then{
fib23=((high_bar-Low_bar)*0.236)+Low_bar;
fib38=((high_bar-Low_bar)*0.382)+Low_bar;
fib50=((high_bar-Low_bar)/2)+Low_bar;
fib62=((high_bar-Low_bar)*0.618)+Low_bar;
fib76=((high_bar-Low_bar)*0.764)+Low_bar;
dinap0=(Low_bar+fib23)/2;
dinap1=(fib23+fib38)/2;
dinap2=(fib38+fib50)/2;
dinap3=(fib50+fib62)/2;
dinap4=(fib62+fib76)/2;
dinap5=(high_bar+fib76)/2;
MoveObject("fib23",OBJ_TRENDLINE,Time[cvstart],fib23,Time[1],fib23,black,1,STYLE_DASH);
SetObjectText("23","23.6","Arial",10,Yellow);
MoveObject("23",OBJ_TEXT,time[0],fib23,time[0],fib23,Yellow);
MoveObject("fib38",OBJ_TRENDLINE,Time[cvstart],fib38,Time[1],fib38,darkred,1,STYLE_DASH);
SetObjectText("38","38.2","Arial",10,Yellow);
MoveObject("38",OBJ_TEXT,time[0],fib38,time[0],fib38,Yellow);
MoveObject("fib50",OBJ_TRENDLINE,Time[cvstart],fib50,Time[1],fib50,black,2,STYLE_SOLID);
SetObjectText("50","50","Arial",10,Yellow);
MoveObject("50",OBJ_TEXT,time[0],fib50,time[0],fib50,Yellow);
MoveObject("fib62",OBJ_TRENDLINE,Time[cvstart],fib62,Time[1],fib62,darkred,1,STYLE_DASH);
SetObjectText("62","61.8","Arial",10,Yellow);
MoveObject("62",OBJ_TEXT,time[0],fib62,time[0],fib62,Yellow);
MoveObject("fib76",OBJ_TRENDLINE,Time[cvstart],fib76,Time[1],fib76,black,1,STYLE_DASH);
SetObjectText("76","76.4","Arial",10,Yellow);
MoveObject("76",OBJ_TEXT,time[0],fib76,time[0],fib76,Yellow);
MoveObject("dinap0",OBJ_TRENDLINE,Time[cvstart],dinap0,Time[1],dinap0,black,1,STYLE_DOT);
MoveObject("dinap1",OBJ_TRENDLINE,Time[cvstart],dinap1,Time[1],dinap1,black,1,STYLE_DOT);
MoveObject("dinap2",OBJ_TRENDLINE,Time[cvstart],dinap2,Time[1],dinap2,black,1,STYLE_DOT);
MoveObject("dinap3",OBJ_TRENDLINE,Time[cvstart],dinap3,Time[1],dinap3,black,1,STYLE_DOT);
MoveObject("dinap4",OBJ_TRENDLINE,Time[cvstart],dinap4,Time[1],dinap4,black,1,STYLE_DOT);
MoveObject("dinap5",OBJ_TRENDLINE,Time[cvstart],dinap5,Time[1],dinap5,black,1,STYLE_DOT);
}

//vert. float lines. these draw the lines that calculate the float
//if you change "trendline" to "Vline" it will draw through oscillators too.might be fun
MoveObject("CVSTART",OBJ_TRENDLINE,Time[cvstart],high_bar,Time[cvstart],Low_bar*point,RoyalBlue,4,STYLE_SOLID);
MoveObject("CVEND",OBJ_TRENDLINE,Time[cvend],high_bar,Time[cvend],Low_bar*point,RoyalBlue,4,STYLE_SOLID);

//vert float predictions. These are only time based.
//see RoyalBlue histogram for real float values.
//if you change "trendline" to "Vline" it will draw through oscillators too.might be fun
if cvend-swing_time>0 then {
MoveObject("swingend",OBJ_TRENDLINE,Time[(cvend-swing_time)+5],high_bar,Time[cvend-swing_time+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend",0,0,0,0);
if cvend-(swing_time*2)>0 then {
MoveObject("swingend2",OBJ_TRENDLINE,Time[(cvend-(swing_time*2))+5],high_bar,Time[cvend-(swing_time*2)+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend2",0,0,0,0);
if cvend-(swing_time*3)>0 then {
MoveObject("swingend3",OBJ_TRENDLINE,Time[(cvend-(swing_time*3))+5],high_bar,Time[cvend-(swing_time*3)+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend3",0,0,0,0);
if cvend-(swing_time*4)>0 then {
MoveObject("swingend4",OBJ_TRENDLINE,Time[(cvend-(swing_time*4))+5],high_bar,Time[cvend-(swing_time*4)+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend4",0,0,0,0);
if cvend-(swing_time*5)>0 then {
MoveObject("swingend5",OBJ_TRENDLINE,Time[(cvend-(swing_time*5))+5],high_bar,Time[cvend-(swing_time*5)+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend5",0,0,0,0);
if cvend-(swing_time*6)>0 then {
MoveObject("swingend6",OBJ_TRENDLINE,Time[cvend-(swing_time*6)+5],high_bar,Time[cvend-(swing_time*6)+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend6",0,0,0,0);
if cvend-(swing_time*7)>0 then {
MoveObject("swingend7",OBJ_TRENDLINE,Time[cvend-(swing_time*7)+5],high_bar,Time[cvend-(swing_time*7)+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend7",0,0,0,0);
if cvend-(swing_time*8)>0 then {
MoveObject("swingend8",OBJ_TRENDLINE,Time[cvend-(swing_time*8)+5],high_bar,Time[cvend-(swing_time*8)+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend8",0,0,0,0);
if cvend-(swing_time*9)>0 then {
MoveObject("swingend9",OBJ_TRENDLINE,Time[cvend-(swing_time*9)+5],high_bar,Time[cvend-(swing_time*9)+5],Low_bar,black,1,STYLE_DOT);
}
else DelObject("swingend9",0,0,0,0);

//comment out anything you"re not using it will help with speed.
If Backtesting = 1 then {
SetGlobalVariable("fib23",fib23);
SetGlobalVariable("fib38",fib38);
SetGlobalVariable("fib50",fib50);
SetGlobalVariable("fib62",fib62);
SetGlobalVariable("fib76",fib76);
SetGlobalVariable("dinap0",dinap0);
SetGlobalVariable("dinap1",dinap1);
SetGlobalVariable("dinap2",dinap2);
SetGlobalVariable("dinap3",dinap3);
SetGlobalVariable("dinap4",dinap4);
SetGlobalVariable("dinap5",dinap5);
SetGlobalVariable("swingtop",high_bar);
SetGlobalVariable("swingbottom",Low_bar);
SetGlobalVariable("CVSTART",CVSTART);
SetGlobalVariable("CVEND",CVEND);
SetGlobalVariable("FLOATV",FLOATV);
SetGlobalVariable("cumulativeV",cumulativeV);
SetGlobalVariable("swing_time",swing_time);
SetGlobalVariable("bars_high",bars_high);
SetGlobalVariable("bars_low",bars_low);
if cvend-swing_time>0 then
SetGlobalVariable("swingend",(cvend-swing_time)+5);
if cvend-(swing_time*2)>0 then
SetGlobalVariable("swingend2",cvend-(swing_time*2)+5);
if cvend-(swing_time*3)>0 then
SetGlobalVariable("swingend3",cvend-(swing_time*3)+5);
if cvend-(swing_time*4)>0 then
SetGlobalVariable("swingend4",cvend-(swing_time*4)+5);
if cvend-(swing_time*5)>0 then
SetGlobalVariable("swingend5",cvend-(swing_time*5)+5);
if cvend-(swing_time*6)>0 then
SetGlobalVariable("swingend6",cvend-(swing_time*6)+5);
if cvend-(swing_time*7)>0 then
SetGlobalVariable("swingend7",cvend-(swing_time*7)+5);
if cvend-(swing_time*8)>0 then
SetGlobalVariable("swingend8",cvend-(swing_time*8)+5);
if cvend-(swing_time*9)>0 then
SetGlobalVariable("swingend9",cvend-(swing_time*9)+5);
}
End;
end;
end;
end;



второй

/*[[
        Name := HL_Activator_Next

        Separate Window  := No
        First Color      := DarkKhaki
        First Draw Type  := Symbol
        First Symbol     := 159
        Use Second Data  := Yes
        Second Color     := Red
        Second Draw Type := Symbol
        Second Symbol    := 159
]]*/

Input:  HL_period(3);
Input:  NumBars(1000);
Var:    alt(0);
Var:    shift(0);
Var:    n(0);
Var:    sumH(0);
Var:    sumL(0);
Var:    MaH(0);
Var:    MaL(0);
Var:    hh(0);
Var:    ll(0);
Var:    cl(0);
Var:    Nbar2(0);
Var:    Nbar(0);
Var:    k(0);
Var:    m(0);
Var:    mm(0);
Array:  ur[99999,2](0);
Array:  h1[99999](0);
Array:  l1[99999](0);

SetLoopCount(0);

if Period == 5 then
   {
   for n = 0 to NumBars
      {
      ur[n,1] = 0;
      ur[n,2] = 0;
      h1[n] = 0;
      l1[n] = 0;
      }
   for shift = NumBars downto 0
      {
      if TimeHour(Time[shift + 1]) != TimeHour(Time[shift]) then
         {
         Nbar = -1;
         k = 1;
         mm = 0;
         n = shift - 15;
         while n <= shift + HL_period * 12 + 5
            {
            if n < 0 then
               {
               Nbar = 0;
               n = 1;
               }
            if TimeHour(Time[n + 1]) != TimeHour(Time[n]) and Nbar == -1 then
               {
               Nbar = n;
               mm = n;
               n++;
               continue;
               }
            if TimeHour(Time[n + 1]) != TimeHour(Time[n]) and Nbar != -1 then
               {
               h1[k] = Highest(2,n,n - Nbar);
               l1[k] = Lowest(1,n,n - Nbar);
               k++;
               Nbar = n;
               }
            n++;
            }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
            {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
            }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[shift,1] = MaH;
         ur[shift,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
         }
      if ur[shift,1] == 0 then
         {
         ur[shift,1] = ur[shift + 1,1];
         ur[shift,2] = ur[shift + 1,2];
         }
      if ll == 1 then
         {
         SetIndexValue2(shift,0);
         SetIndexValue(shift,ur[shift,2]);
         }
      if hh == 1 then
         {
         SetIndexValue(shift,0);
         SetIndexValue2(shift,ur[shift,1]);
         }
      }
   }

if Period == 15 then
   {
   for n = 0 to NumBars
      {
      ur[n,1] = 0;
      ur[n,2] = 0;
      h1[n] = 0;
      l1[n] = 0;
      }
   for shift = NumBars downto 0
      {
      if TimeHour(Time[shift + 1]) != TimeHour(Time[shift]) then
         {
         Nbar = -1;
         k = 1;
         mm = 0;
         n = shift - 5;
         while n <= shift + HL_period * 4 + 2
            {
            if n < 0 then
               {
               Nbar = 0;
               n = 1;
               }
            if TimeHour(Time[n + 1]) != TimeHour(Time[n]) and Nbar == -1 then
               {
               Nbar = n;
               mm = n;
               n++;
               continue;
               }
            if TimeHour(Time[n + 1]) != TimeHour(Time[n]) and Nbar != -1 then
               {
               h1[k] = Highest(2,n,n - Nbar);
               l1[k] = Lowest(1,n,n - Nbar);
               k++;
               Nbar = n;
               }
            n++;
            }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
            {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
            }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[shift,1] = MaH;
         ur[shift,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
         }
      if ur[shift,1] == 0 then
         {
         ur[shift,1] = ur[shift + 1,1];
         ur[shift,2] = ur[shift + 1,2];
         }
      if ll == 1 then
         {
         SetIndexValue2(shift,0);
         SetIndexValue(shift,ur[shift,2]);
         }
      if hh == 1 then
         {
         SetIndexValue(shift,0);
         SetIndexValue2(shift,ur[shift,1]);
         }
      }
   }

if Period == 30 then
   {
   for n = 0 to NumBars
      {
      ur[n,1] = 0;
      ur[n,2] = 0;
      h1[n] = 0;
      l1[n] = 0;
      }
   for shift = NumBars downto 0
      {
      if (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 0) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 4) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 8) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 12) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 16) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 20) then
         {
         Nbar = -1;
         k = 1;
         mm = 0;
         n = shift - 10;
         while n <= shift + HL_period * 8 + 5
            {
            if n < 0 then
               {
               Nbar = 0;
               n = 1;
               }
            if ((TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 0) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 4) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 8) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 12) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 16) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 20)) and Nbar == -1 then
               {
               Nbar = n;
               mm = n;
               n++;
               continue;
               }
            if ((TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 0) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 4) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 8) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 12) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 16) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 20)) and Nbar != -1 then
               {
               h1[k] = Highest(2,n,n - Nbar);
               l1[k] = Lowest(1,n,n - Nbar);
               k++;
               Nbar = n;
               }
            n++;
            }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
            {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
            }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[shift,1] = MaH;
         ur[shift,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
         }
      if ur[shift,1] == 0 then
         {
         ur[shift,1] = ur[shift + 1,1];
         ur[shift,2] = ur[shift + 1,2];
         }
      if ll == 1 then
         {
         SetIndexValue2(shift,0);
         SetIndexValue(shift,ur[shift,2]);
         }
      if hh == 1 then
         {
         SetIndexValue(shift,0);
         SetIndexValue2(shift,ur[shift,1]);
         }
      }
   }

if Period == 60 then
   {
   for n = 0 to NumBars
      {
      ur[n,1] = 0;
      ur[n,2] = 0;
      h1[n] = 0;
      l1[n] = 0;
      }
   for shift = NumBars downto 0
      {
      if (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 0) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 4) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 8) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 12) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 16) or (TimeMinute(Time[shift]) == 0 and TimeHour(Time[shift]) == 20) then
         {
         Nbar = -1;
         k = 1;
         mm = 0;
         n = shift - 6;
         while n <= shift + HL_period * 4 + 3
            {
            if n < 0 then
               {
               Nbar = 0;
               n = 1;
               }
            if ((TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 0) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 4) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 8) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 12) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 16) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 20)) and Nbar == -1 then
               {
               Nbar = n;
               mm = n;
               n++;
               continue;
               }
            if ((TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 0) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 4) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 8) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 12) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 16) or (TimeMinute(Time[n]) == 0 and TimeHour(Time[n]) == 20)) and Nbar != -1 then
               {
               h1[k] = Highest(2,n,n - Nbar);
               l1[k] = Lowest(1,n,n - Nbar);
               k++;
               Nbar = n;
               }
            n++;
            }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
            {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
            }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[shift,1] = MaH;
         ur[shift,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
         }
      if ur[shift,1] == 0 then
         {
         ur[shift,1] = ur[shift + 1,1];
         ur[shift,2] = ur[shift + 1,2];
         }
      if ll == 1 then
         {
         SetIndexValue2(shift,0);
         SetIndexValue(shift,ur[shift,2]);
         }
      if hh == 1 then
         {
         SetIndexValue(shift,0);
         SetIndexValue2(shift,ur[shift,1]);
         }
      }
   }

if Period == 240 then
   {
   for n = 0 to NumBars
      {
      ur[n,1] = 0;
      ur[n,2] = 0;
      h1[n] = 0;
      l1[n] = 0;
      }
   for shift = NumBars downto 0
      {
      if TimeDay(Time[shift + 1]) != TimeDay(Time[shift]) then
         {
         Nbar = -1;
         k = 1;
         mm = 0;
         n = shift - 8;
         while n <= shift + HL_period * 8 + 4
            {
            if n < 0 then
               {
               Nbar = 0;
               n = 1;
               }
            if TimeDay(Time[n + 1]) != TimeDay(Time[n]) and Nbar == -1 then
               {
               Nbar = n;
               mm = n;
               n++;
               continue;
               }
            if TimeDay(Time[n + 1]) != TimeDay(Time[n]) and Nbar != -1 then
               {
               h1[k] = Highest(2,n,n - Nbar);
               l1[k] = Lowest(1,n,n - Nbar);
               k++;
               Nbar = n;
               }
            n++;
            }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
            {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
            }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[shift,1] = MaH;
         ur[shift,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
         }
      if ur[shift,1] == 0 then
         {
         ur[shift,1] = ur[shift + 1,1];
         ur[shift,2] = ur[shift + 1,2];
         }
      if ll == 1 then
         {
         SetIndexValue2(shift,0);
         SetIndexValue(shift,ur[shift,2]);
         }
      if hh == 1 then
         {
         SetIndexValue(shift,0);
         SetIndexValue2(shift,ur[shift,1]);
         }
      }
   }

if Period == 1440 then
   {
   for n = 0 to NumBars
      {
      ur[n,1] = 0;
      ur[n,2] = 0;
      h1[n] = 0;
      l1[n] = 0;
      }
   for shift = NumBars downto 0
      {
      if TimeDayOfWeek(Time[shift + 1]) == 6 and TimeDayOfWeek(Time[shift]) == 2 then
         {
         Nbar = -1;
         k = 1;
         mm = 0;
         n = shift - 6;
         while n <= shift + HL_period * 5 + 3
            {
            if n < 0 then
               {
               Nbar = 0;
               n = 1;
               }
            if TimeDayOfWeek(Time[n + 1]) == 6 and TimeDayOfWeek(Time[n]) == 2 and Nbar == -1 then
               {
               Nbar = n;
               mm = n;
               n++;
               continue;
               }
            if TimeDayOfWeek(Time[n + 1]) == 6 and TimeDayOfWeek(Time[n]) == 2 and Nbar != -1 then
               {
               h1[k] = Highest(2,n,n - Nbar);
               l1[k] = Lowest(1,n,n - Nbar);
               k++;
               Nbar = n;
               }
            n++;
            }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
            {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
            }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[shift,1] = MaH;
         ur[shift,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
         }
      if ur[shift,1] == 0 then
         {
         ur[shift,1] = ur[shift + 1,1];
         ur[shift,2] = ur[shift + 1,2];
         }
      if ll == 1 then
         {
         SetIndexValue2(shift,0);
         SetIndexValue(shift,ur[shift,2]);
         }
      if hh == 1 then
         {
         SetIndexValue(shift,0);
         SetIndexValue2(shift,ur[shift,1]);
         }
      }
   }

if Period == 10080 then
   {
   for n = 0 to NumBars
      {
      ur[n,1] = 0;
      ur[n,2] = 0;
      h1[n] = 0;
      l1[n] = 0;
      }
   for shift = NumBars downto 0
      {
      if TimeMonth(Time[shift + 1]) != TimeMonth(Time[shift]) then
         {
         Nbar = -1;
         k = 1;
         mm = 0;
         n = shift - 8;
         while n <= shift + HL_period * 8 + 4
            {
            if n < 0 then
               {
               Nbar = 0;
               n = 1;
               }
            if TimeMonth(Time[n + 1]) != TimeMonth(Time[n]) and Nbar == -1 then
               {
               Nbar = n;
               mm = n;
               n++;
               continue;
               }
            if TimeMonth(Time[n + 1]) != TimeMonth(Time[n]) and Nbar != -1 then
               {
               h1[k] = Highest(2,n,n - Nbar);
               l1[k] = Lowest(1,n,n - Nbar);
               k++;
               Nbar = n;
               }
            n++;
            }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
            {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
            }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[shift,1] = MaH;
         ur[shift,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
         }
      if ur[shift,1] == 0 then
         {
         ur[shift,1] = ur[shift + 1,1];
         ur[shift,2] = ur[shift + 1,2];
         }
      if ll == 1 then
         {
         SetIndexValue2(shift,0);
         SetIndexValue(shift,ur[shift,2]);
         }
      if hh == 1 then
         {
         SetIndexValue(shift,0);
         SetIndexValue2(shift,ur[shift,1]);
         }
      }
   }
 
Хотябы помогите новичку - моя попытка переписать наткнулась на ошибку, с которой ни как не могу справится, может кто намекнет:

//+------------------------------------------------------------------+
//|                                            HL_Actevator_mext.mq4 |
//|                                                                  |
//|                                                  Conversion only |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Tomato
#property indicator_color2 Cornsilk
//---- input parameters
extern int HL_period=3;
extern int NumBars=1000;
//---- buffers
double Up[];
double Down[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{

//---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,Up);
   SetIndexBuffer(1,Down);
//----
//----
 return(0);
 }
//+------------------------------------------------------------------+
//| Hi-Lo                                                         |
//+------------------------------------------------------------------+
int start()
{
  SetIndexDrawBegin(0,Bars-NumBars+HL_period);
  SetIndexDrawBegin(1,Bars-NumBars+HL_period);
   
 // int i;
 //  int counted_bars=IndicatorCounted();
 //    bool Pr=false, PrevPr=false;
 //  double val,val2;
   int alt=0;
   int shift=0;
   int n=0;
   int sumH=0;
   int sumL=0;
   int MaH=0;
   int MaL=0;
   int hh=0;
   int ll=0;
   int cl=0;
   int Nbar2=0;
   int Nbar=0;
   int k=0;
   int m=0;
   int mm=0;
   int ur[99999,2];
   int h1[99999];
   int l1[99999];
//   if(NumBars<=HL_period) return(0);
      if (Period()==PERIOD_M5)
       { 
       for (n=0;n<=NumBars;n++)
           {
           ur[n,1] = 0;
           ur[n,2] = 0;
           h1[n] = 0;
           l1[n] = 0;
           }
       for (shift=NumBars;shift=0;shift--)
           { 
           if (TimeHour(CurTime(shift + 1))!=TimeHour(CurTime(shift))
                {
                Nbar = -1;
                k = 1;
                mm = 0;
                n = shift - 15;
                while(n <= shift + HL_period * 12 + 5)
                    {
                    if (n<0)
                        {
                        Nbar = 0;
                        n = 1;
                        }
                      
                    if ((TimeHour(CurTime(n + 1))!=TimeHour(CurTime(n))&& (Nbar == -1))
                       {Nbar = n;
                        mm = n;
                        n++;
                          continue;
                        }
                      }
                    if ((TimeHour(CurTime(n + 1))!=TimeHour(CurTime(n))&& (Nbar != -1))
                        {
                        h1[k] = Highest(2,n,n - Nbar);
                        l1[k] = Lowest(1,n,n - Nbar);
                        k++;
                        Nbar = n;
                        }
                    n++;
                    }//while
               MaH = 0;
               MaL = 0;
               for (n = 1;n <=HL_period;n++)
                   {
                    MaH = MaH + High[h1[n]];
                    MaL = MaL + Low[l1[n]];
                    }
               MaH = MaH / HL_period;
               MaL = MaL / HL_period;
               ur[shift,1] = MaH;
               ur[shift,2] = MaL;
         
               if(Close[mm + 1] >= MaH)
                { 
                ll = 1; hh = 0;
                 }
               if(Close[mm + 1] <= MaL )
                {
                 hh = 1; ll = 0;
                  }
            
                if(ur[shift,1] == 0)
                 {
              ur[shift,1] = ur[shift + 1,1];
              ur[shift,2] = ur[shift + 1,2];
             }
   }

           if (ll == 1 )
              (
              Up[shift]=0;
              Down[shift]=ur[shift,2];
               }
          if (hh == 1)
            {
           Up[shift]=0;
           Down[shift]=ur[shift,1];
              }
}

}



Пишет - '}' - unbalanced parentheses

если убираю последнюю фигурную скобку - пишет
'\end_of_program' - unbalanced left parenthesis
____________________
Заранее благодарю за помощь!!!

 
//+------------------------------------------------------------------+
//|                                            HL_Actevator_mext.mq4 |
//|                                                                  |
//|                                                  Conversion only |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Tomato
#property indicator_color2 Cornsilk

//---- input parameters
extern int HL_period=3;
extern int NumBars=1000;

//---- buffers
double Up[];
double Down[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{

   //---- indicator line
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,Up);
   SetIndexBuffer(1,Down);

   return(0);
 }

//+------------------------------------------------------------------+
//| Hi-Lo                                                         |
//+------------------------------------------------------------------+
int start()
{
	SetIndexDrawBegin(0,Bars-NumBars+HL_period);
	SetIndexDrawBegin(1,Bars-NumBars+HL_period);
   
 // int i;
 //  int counted_bars=IndicatorCounted();
 //    bool Pr=false, PrevPr=false;
 //  double val,val2;
	int alt=0;
	int shift=0;
	int n=0;
	int sumH=0;
	int sumL=0;
	int MaH=0;
	int MaL=0;
	int hh=0;
	int ll=0;
	int cl=0;
	int Nbar2=0;
	int Nbar=0;
	int k=0;
	int m=0;
	int mm=0;
	int ur[99999,2];
	int h1[99999];
	int l1[99999];
//   if(NumBars<=HL_period) return(0);
	if (Period()==PERIOD_M5)
	{ 
		for (n=0;n<=NumBars;n++)
		{
			ur[n,1] = 0;
			ur[n,2] = 0;
			h1[n] = 0;
			l1[n] = 0;
		}
		
		for (shift = NumBars; shift == 0; shift--)
		{ 
			if(TimeHour(iTime(NULL, 0, shift + 1)) != TimeHour(iTime(NULL, 0, shift)))
			{
				Nbar = -1;
				k = 1;
				mm = 0;
				n = shift - 15;
				while(n <= shift + HL_period * 12 + 5)
				{
					if (n<0)
					{
						Nbar = 0;
						n = 1;
               }
                      
               if ((TimeHour(iTime(NULL, 0, n + 1)) != TimeHour(iTime(NULL, 0, n))) && (Nbar == -1))
					{
						Nbar = n;
						mm = n;
						n++;
						continue;
               }
                    
					if ((TimeHour(iTime(NULL, 0, n + 1)) != TimeHour(iTime(NULL, 0, n))) && (Nbar != -1))
					{
						h1[k] = Highest(2,n,n - Nbar);
						l1[k] = Lowest(1,n,n - Nbar);
						k++;
						Nbar = n;
					}

					n++;
				
				}//while
            
				MaH = 0;
				MaL = 0;
				
				for (n = 1; n <= HL_period; n++)
				{
					MaH = MaH + High[h1[n]];
					MaL = MaL + Low[l1[n]];
				}
            
				MaH = MaH / HL_period;
				MaL = MaL / HL_period;
				ur[shift,1] = MaH;
				ur[shift,2] = MaL;
         
				if(Close[mm + 1] >= MaH)
				{ 
            	ll = 1;
					hh = 0;
				}
            
				if(Close[mm + 1] <= MaL )
				{
					hh = 1;
					ll = 0;
				}
            
				if(ur[shift,1] == 0)
				{
					ur[shift,1] = ur[shift + 1,1];
					ur[shift,2] = ur[shift + 1,2];
				}
			}

         if(ll == 1 )
         {
				Up[shift]=0;
				Down[shift]=ur[shift,2];
			}
         
			if(hh == 1)
			{
				Up[shift]=0;
				Down[shift]=ur[shift,1];
			}
		}
	}
}
 
СПАСИБО!!!
 
СПАСИБО!!!

Имейте ввиду HL_Activator_Next - этот индюк перерисовывает историю на нескольких предыдущих барах
 
Посмотрел HL_Activator_Next, заинтересовался, никак не пойму алгоритм, а просто в тупую переделывать на четверку не могу
Вот очищенный и оптимизированный код :
/*[[
        Name := HL_Activator_Next

        Separate Window  := No
        First Color      := DarkKhaki
        First Draw Type  := Symbol
        First Symbol     := 159
        Use Second Data  := Yes
        Second Color     := Red
        Second Draw Type := Symbol
        Second Symbol    := 159
]]*/

Input:  HL_period(3);
Input:  NumBars(1000);
Var:    cb(0);
Var:    n(0);
Var:    Nbar(0);
Var:    k(0);
Var:    MaH(0);
Var:    MaL(0);
Var:    hh(0);
Var:    ll(0);
Var:    mm(0);
Array:  ur[99999,2](0);
Array:  h1[99999](0);
Array:  l1[99999](0);

SetLoopCount(0);

for n = 0 to NumBars
{
   ur[n,1] = 0;
   ur[n,2] = 0;
   h1[n] = 0;
   l1[n] = 0;
}

for cb = NumBars downto 0
   {
   Nbar = -1;
   k = 1;
   mm = 0;

//-----------------------------------------------------------------------------
   if Period == 5 then //если график - М5
   {
      if TimeHour(Time[cb + 1]) != TimeHour(Time[cb]) then
      {
         n = cb - 15;
         while n <= cb + HL_period * 12 + 5
         {
            if n < 0 then
            {
               Nbar = 0;
               n = 1;
            }
            if TimeHour(Time[n + 1]) != TimeHour(Time[n])  then
            {
               if Nbar == -1 then
               {
               		Nbar = n;
               		mm = n;
               		n++;
               		continue;
               }
               else
               {
               		h1[k] = Highest(2,n,n - Nbar);
               		l1[k] = Lowest(1,n,n - Nbar);
               		k++;
               		Nbar = n;
               };
            }
            n++;
         }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
         {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
         }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[cb,1] = MaH;
         ur[cb,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
      }
      if ur[cb,1]==0 then
      {
         ur[cb,1] = ur[cb + 1,1];
         ur[cb,2] = ur[cb + 1,2];
      }
      if ll == 1 then
      {
         SetIndexValue2(cb,0);
         SetIndexValue(cb,ur[cb,2]);
      }
      else
      {
      	if hh == 1 then
      	{
        	SetIndexValue(cb,0);
         	SetIndexValue2(cb,ur[cb,1]);
      	}
	  };
   }
   else {
//-----------------------------------------------------------------------------

   if Period == 15 then //если график - М15
   {
      if TimeHour(Time[cb + 1]) != TimeHour(Time[cb]) then
      {
         n = cb - 5;
         while n <= cb + HL_period * 4 + 2
         {
            if n < 0 then
            {
               Nbar = 0;
               n = 1;
            }
            if TimeHour(Time[n + 1]) != TimeHour(Time[n]) then
            {
				if Nbar==-1 then
               	{
               		Nbar = n;
               		mm = n;
               		n++;
               		continue;
               	}
            	else
               	{
               		h1[k] = Highest(2,n,n - Nbar);
               		l1[k] = Lowest(1,n,n - Nbar);
               		k++;
               		Nbar = n;
               	};
         	}
            n++;
         }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
         {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
         }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[cb,1] = MaH;
         ur[cb,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
      }
      if ur[cb,1]==0 then
      {
         ur[cb,1] = ur[cb + 1,1];
         ur[cb,2] = ur[cb + 1,2];
      }
      if ll == 1 then
      {
         SetIndexValue2(cb,0);
         SetIndexValue(cb,ur[cb,2]);
      }
      else
      {
      	if hh == 1 then
      	{
        	SetIndexValue(cb,0);
         	SetIndexValue2(cb,ur[cb,1]);
      	}
	  };
   }
   else {
//-----------------------------------------------------------------------------

   if Period == 30 then //если график - М30
   {
      if (TimeMinute(Time[cb])==0 & (TimeHour(Time[cb])==0 | TimeHour(Time[cb])==4 | TimeHour(Time[cb])==8 | 
          TimeHour(Time[cb])==12 | TimeHour(Time[cb])==16 | TimeHour(Time[cb])==20)) then
      {
         n = cb - 10;
         while n <= cb + HL_period * 8 + 5
         {
            if n < 0 then
            {
               Nbar = 0;
               n = 1;
            }
            if (TimeMinute(Time[n])==0 & (TimeHour(Time[n])==0 | TimeHour(Time[n])==4 | TimeHour(Time[n])==8 |
			    TimeHour(Time[n])==12 | TimeHour(Time[n])==16 | TimeHour(Time[n])==20)) then
            {
				if Nbar==-1 then
               	{
               		Nbar = n;
               		mm = n;
               		n++;
               		continue;
               	}
				else
               	{
               		h1[k] = Highest(2,n,n - Nbar);
               		l1[k] = Lowest(1,n,n - Nbar);
               		k++;
               		Nbar = n;
               	};
            }
            n++;
         }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
         {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
         }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[cb,1] = MaH;
         ur[cb,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
      }
      if ur[cb,1]==0 then
      {
         ur[cb,1] = ur[cb + 1,1];
         ur[cb,2] = ur[cb + 1,2];
      }
      if ll == 1 then
      {
         SetIndexValue2(cb,0);
         SetIndexValue(cb,ur[cb,2]);
      }
      else
      {
      	if hh == 1 then
      	{
        	SetIndexValue(cb,0);
         	SetIndexValue2(cb,ur[cb,1]);
      	}
	  };
   }
   else {
//-----------------------------------------------------------------------------

   if Period == 60 then //если график - H1
      {
      if (TimeMinute(Time[cb])==0 & (TimeHour(Time[cb])==0 | TimeHour(Time[cb])==4 | TimeHour(Time[cb])==8 | 
          TimeHour(Time[cb])==12 | TimeHour(Time[cb])==16 | TimeHour(Time[cb])==20)) then
      {
         n = cb - 6;
         while n <= cb + HL_period * 4 + 3
         {
            if n < 0 then
            {
               Nbar = 0;
               n = 1;
            }
			if (TimeMinute(Time[n])==0 & (TimeHour(Time[n])==0 | TimeHour(Time[n])==4 | TimeHour(Time[n])==8 |
			    TimeHour(Time[n])==12 | TimeHour(Time[n])==16 | TimeHour(Time[n])==20)) then 
			{
            	if Nbar==-1 then
            	{
               		Nbar = n;
               		mm = n;
               		n++;
               		continue;
               	}
				else
               	{
               		h1[k] = Highest(2,n,n - Nbar);
               		l1[k] = Lowest(1,n,n - Nbar);
               		k++;
               		Nbar = n;
               	};
            }
            n++;
         }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
         {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
         }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[cb,1] = MaH;
         ur[cb,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
      }
      if ur[cb,1]==0 then
      {
         ur[cb,1] = ur[cb + 1,1];
         ur[cb,2] = ur[cb + 1,2];
      }
      if ll == 1 then
      {
         SetIndexValue2(cb,0);
         SetIndexValue(cb,ur[cb,2]);
      }
      else
      {
      	if hh == 1 then
      	{
        	SetIndexValue(cb,0);
         	SetIndexValue2(cb,ur[cb,1]);
      	}
	  };
   }
   else {
//-----------------------------------------------------------------------------

   if Period == 240 then //если график - H4
      {
      if TimeDay(Time[cb + 1]) != TimeDay(Time[cb]) then
      {
         n = cb - 8;
         while n <= cb + HL_period * 8 + 4
         {
            if n < 0 then
            {
               Nbar = 0;
               n = 1;
            }
            if TimeDay(Time[n + 1]) != TimeDay(Time[n]) then
            {
               	if Nbar == -1 then
               	{
               		Nbar = n;
               		mm = n;
               		n++;
               		continue;
               	}
            	else
               	{
               		h1[k] = Highest(2,n,n - Nbar);
               		l1[k] = Lowest(1,n,n - Nbar);
               		k++;
               		Nbar = n;
               	};
            }
            n++;
         }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
         {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
         }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[cb,1] = MaH;
         ur[cb,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
      }
      if ur[cb,1]==0 then
      {
         ur[cb,1] = ur[cb + 1,1];
         ur[cb,2] = ur[cb + 1,2];
      }
      if ll == 1 then
      {
         SetIndexValue2(cb,0);
         SetIndexValue(cb,ur[cb,2]);
      }
      else
      {
      	if hh == 1 then
      	{
        	SetIndexValue(cb,0);
         	SetIndexValue2(cb,ur[cb,1]);
      	}
	  };
   }
   else {
//-----------------------------------------------------------------------------

   if Period == 1440 then //если график - D1
   {
      if TimeDayOfWeek(Time[cb + 1]) == 6 & TimeDayOfWeek(Time[cb]) == 2 then
      {
         n = cb - 6;
         while n <= cb + HL_period * 5 + 3
         {
            if n < 0 then
            {
               Nbar = 0;
               n = 1;
            }
            if TimeDayOfWeek(Time[n + 1]) == 6 & TimeDayOfWeek(Time[n]) == 2 then
            {
            	if Nbar==-1 then
            	{
               		Nbar = n;
               		mm = n;
               		n++;
               		continue;
            	}
            	else
               	{
               		h1[k] = Highest(2,n,n - Nbar);
               		l1[k] = Lowest(1,n,n - Nbar);
               		k++;
               		Nbar = n;
               	};
            }
            n++;
         }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
         {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
         }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[cb,1] = MaH;
         ur[cb,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
      }
      if ur[cb,1]==0 then
      {
         ur[cb,1] = ur[cb + 1,1];
         ur[cb,2] = ur[cb + 1,2];
      }
      if ll == 1 then
      {
         SetIndexValue2(cb,0);
         SetIndexValue(cb,ur[cb,2]);
      }
      else
      {
      	if hh == 1 then
      	{
        	SetIndexValue(cb,0);
         	SetIndexValue2(cb,ur[cb,1]);
      	}
	  };
   }
   else {
//-----------------------------------------------------------------------------

   if Period == 10080 then //если график - W1
   {
      if TimeMonth(Time[cb + 1]) != TimeMonth(Time[cb]) then
      {
         n = cb - 8;
         while n <= cb + HL_period * 8 + 4
         {
            if n < 0 then
            {
               Nbar = 0;
               n = 1;
            }
            if TimeMonth(Time[n + 1]) != TimeMonth(Time[n]) then
            {
				if Nbar == -1 then
				{
					Nbar = n;
					mm = n;
					n++;
					continue;
            	}
				else
            	{
					h1[k] = Highest(2,n,n - Nbar);
					l1[k] = Lowest(1,n,n - Nbar);
            		k++;
    		        Nbar = n;
	            };
            }
            n++;
         }
         MaH = 0;
         MaL = 0;
         for n = 1 to HL_period
         {
            MaH = MaH + High[h1[n]];
            MaL = MaL + Low[l1[n]];
         }
         MaH = MaH / HL_period;
         MaL = MaL / HL_period;
         ur[cb,1] = MaH;
         ur[cb,2] = MaL;
         if Close[mm + 1] >= MaH then { ll = 1; hh = 0; }
         if Close[mm + 1] <= MaL then { hh = 1; ll = 0; }
      }
      if ur[cb,1]==0 then
      {
         ur[cb,1] = ur[cb + 1,1];
         ur[cb,2] = ur[cb + 1,2];
      }
      if ll == 1 then
      {
         SetIndexValue2(cb,0);
         SetIndexValue(cb,ur[cb,2]);
      }
      else
      {
      	if hh == 1 then
      	{
        	SetIndexValue(cb,0);
         	SetIndexValue2(cb,ur[cb,1]);
      	}
	  };
	}
	}}}}}}
//-----------------------------------------------------------------------------
   };

может кто приведет алгоритм или ссылку где можно прочитать, единственное что нашел что связано с разработками Гана, а материала по данной теме у меня нет

 
СПАСИБО!!!

Имейте ввиду HL_Activator_Next - этот индюк перерисовывает историю на нескольких предыдущих барах

Я это поняла по работе с индикатором - не вижу в этом недостатка, просто важно об этом знать при принятии решений на основании показаний этого индикатора
 
очищенный и оптимозированный код посмотрела сегодня в процессе - по моему все отлично, работает аналогично исходному. Пока к сожалению не хватает умения переделать - пытаюсь переделать, для начала - пытаюсь заставить заработать часть, которая обсчитывает пятиминутки, но он ни как не хочет ни чего рисовать :-(
Даже тестовую печать не удается заставить написать
Может кто подскажет, что я не так делаю

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Black
#property indicator_color2 DeepSkyBlue
//---- input parameters
extern int       HL_period=3;
extern int       NumBars=1000;
//---- buffers
double up[];
double dn[];
double ur1[];
double ur2[];
int h1[];
int l1[];
int shift=0;
int nbar=0;
int cb;
Print("TEST");
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(0,up);
   SetIndexBuffer(1,dn);
   SetIndexArrow(1,159);
   SetIndexArrow(0,159);
//   SetIndexEmptyValue(0,0.0);
//   SetIndexEmptyValue(1,0.0);
 Print("TEST");
//----

//----
//   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
//   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()

  {SetIndexDrawBegin(0,Bars-NumBars+HL_period);
   SetIndexDrawBegin(1,Bars-NumBars+HL_period);
   int counted_bars=IndicatorCounted(), n, Nbar, k, hh, ll, mm, limit;
   double MaH, MaL;
   Print("TEST");
//---- 
// Print("TEST");
//   if(counted_bars!=0)
//   {
//      if(Bars-1-counted_bars>=0) limit=Bars-1-counted_bars; else limit=0;
//   }
//   else
//   {
//      limit=Bars-1;
// }
//----
 for(n=0;n>=NumBars;n++)
   {
      ur1[n]=0.0;
      ur2[n]=0.0;
      h1[n]=0.0;
      l1[n]=0.0;
   }

   for(shift=NumBars;shift>=0;shift--) //глобальный цикл по всем барам
   {
      Nbar = -1;
      k = 1;
      mm = 0;
      Print("Расчет "+cb+" бара");
//----------------------- Расчет на M5  ------------------------------------------------------
   if( Period()==PERIOD_M5 ) //если график - М5
      {
         if( TimeHour(Time[shift+1])!=TimeHour(Time[shift]))
         {
            n=shift-15;
            Print("---- n="+n);
            while( n<=shift+HL_period*12+5 )
            {
               if( n<0 )
               {
                  Nbar=0;
                  n=1;
               }
               if( TimeHour(Time[n+1])!=TimeHour(Time[n]) && Nbar==-1 )
               {
                  Nbar=n;
                  mm=n;
                  n++;
                  continue;
               }
               Print("---- Nbar="+Nbar+" n="+n+" mm"+mm);
               if( TimeHour(Time[n+1])!=TimeHour(Time[n]) && Nbar!= -1 )
               {
 //                 h1[k]=High[Highest(NULL,0,MODE_HIGH,n-Nbar,n)];
 //                 l1[k]=Low[Lowest(NULL,0,MODE_LOW,n-Nbar,n)];
 //                 Print("---- Nbar="+Nbar+" n="+n+" mm"+mm+" h1["+k+"]="+h1[k]+" l1["+k+"]="+l1[k]);
                  k++;
                  Nbar=n;
                  mm=n;
                   n++;
                   continue;
                   
               }
               if( TimeHour(Time[n+1])!=TimeHour(Time[n]) && Nbar!= -1 )
               {
                h1[k]=High[Highest(NULL,0,MODE_HIGH,n-Nbar,n)];
                l1[k]=Low[Lowest(NULL,0,MODE_LOW,n-Nbar,n)];
                k++;
                nbar=n;
                }
                n++;
                }
                
            
            MaH=0;
            MaL=0;
            for( n=1;n<=HL_period;n++ )
            {
               MaH=MaH+High[h1[n]];
               MaL=MaL+Low[l1[n]];
            }
            MaH = MaH/HL_period;
            MaL = MaL/HL_period;
            ur1[shift]=MaH;
            ur2[shift]=MaL;
            if( Close[mm+1]>=MaH) 
            {
               ll=1;
               hh=0; 
            }
            if( Close[mm+1]<=MaL)
            {
               hh=1; ll=0; 
            }
         }
         if (ur1[shift]==0)
         {
            ur1[shift]=ur1[shift+1];
            ur2[shift]=ur2[shift+2];
         }
         if( ll==1 )
         {
 //           up[shift]=ur2[shift];
 //           dn[shift]=0.0;
         up[shift]=ur2[shift];
         dn[shift]=0;
         }
         if( hh==1 )
         {
            up[shift]=0;
            dn[shift]=ur1[shift];
         }
      }
   //else {
//----------------------- Конец расчета на M5  -----------------------------------------------
//----------------------- Расчет на M15 ------------------------------------------------------
      
//----------------------- Конец расчета на M15 -----------------------------------------------
  }
Print("TEST");   return(0);
  }
//+------------------------------------------------------------------+
 
СПАСИБО!!!

Имейте ввиду HL_Activator_Next - этот индюк перерисовывает историю на нескольких предыдущих барах

Я это поняла по работе с индикатором - не вижу в этом недостатка, просто важно об этом знать при принятии решений на основании показаний этого индикатора


Как же можно принимать во внимание показания индикатора, когда Вы их не знаете ? и не знаете сколько и каких будет изменено ? Этот индикатор изменяет показания по истории до пяти баров назад. Просто он сейчас может показывать, что если бы Вы выставили позицию пять баров (или три) бара назад, то было бы Вам счастье. Второй пример - выставляете ордер с учетом его показаний, а потом после изменеия по истории оказывается, что показывал то он в противоположную сторону.
Если это не является с Вашей точки зрения недостатками, то советую поплотнее сесть за изучение ТехАнализа.

Удачи.
 
Не думаю, что кто то принимает решение на основании только одного индикатора. а этот индикатор, на мой взгляд очень хорошо показывает направление тренда, и по моему не плохо сигнализирует - о приближении изменений. По крайней мере, из всех индикаторов, которые я видела - он лучший. А тактику использования этого конкретного индикатора можно обсудить отдельно. О себе могу сказать лишь одно - мне этот индикатор очень помогает, единственная трудность - что из за него мне приходится держать запущенными одновременно Mt3 и Mt4 и переключаться между окнами. Так что - я буду счастлива, если смогу перевести этот индикатор на MT4
 
что-то застопорился здесь:
h1[k]=High[Highest(NULL,0,MODE_HIGH,(n-Nbar),n)];
l1[k]=Low[Lowest(NULL,0,MODE_LOW,(n-Nbar),n)];
Print("----   k= "+k+" Nbar= "+Nbar+" n= "+n+" h1["+k+"]= "+h1[k]+" l1["+k+"]= "+l1[k]+" "+(Low[Lowest(NULL,0,MODE_LOW,(n-Nbar),n)])+" "+(High[Lowest(NULL,0,MODE_HIGH,(n-Nbar),n)]) );



на выходе получаю:

----   k= 1 Nbar= 965 n= 977 h1[1]= 0.00000000 l1[1]= 0.00000000 1.74330000 1.74350000
----   k= 2 Nbar= 977 n= 986 h1[2]= 0.00000000 l1[2]= 0.00000000 1.74450000 1.74520000
----   k= 3 Nbar= 986 n= 996 h1[3]= 0.00000000 l1[3]= 0.00000000 1.74580000 1.74620000
----   k= 4 Nbar= 996 n= 1006 h1[4]= 0.00000000 l1[4]= 0.00000000 1.74480000 1.74580000
----   k= 5 Nbar= 1006 n= 1017 h1[5]= 0.00000000 l1[5]= 0.00000000 1.74620000 1.74680000

т.е. хайжест и лоувест отдельно считаются а вот в буфер типа дабл никак не хотят :(