//+------------------------------------------------------------------+
//| Zigzag2_R_Color_Fibo_Grand_x3_Stat_Full_Line_HTF.mq5 |
//| Copyright © 2019, Nikolay Kositsin |
//| Khabarovsk, farria@mail.redcom.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2019, Nikolay Kositsin"
#property link "farria@mail.redcom.ru"
//--- =><5@ 25@A88 8=48:0B>@0
#property version "1.60"
#property description "Zigzag2_R_Color_Fibo_Grand_x3_Stat_Full_Arr A D8:A8@>20==K< 2> 2E>4=KE ?0@0<5B@0E B09<D@59<><"
//---- >B@8A>2:0 8=48:0B>@0 2 3;02=>< >:=5
#property indicator_chart_window
//---- 4;O @0AGQB0 8 >B@8A>2:8 8=48:0B>@0 8A?>;L7>20= 4204F0BL >48= 1CD5@
#property indicator_buffers 22
//---- 8A?>;L7>20=> 2A53> 4204F0BL 3@0D8G5A:8E ?>AB@>5=89
#property indicator_plots 20
//+----------------------------------------------+
//| >1JO2;5=85 :>=AB0=B |
//+----------------------------------------------+
#define RESET 0 // >=AB0=B0 4;O 2>72@0B0 B5@<8=0;C :><0=4K =0 ?5@5AG5B 8=48:0B>@0
#define INDICATOR_NAME "Zigzag2_R_Color_Fibo_Grand_x3_Stat_Full_Line_HTF" // >=AB0=B0 4;O 8<5=8 8=48:0B>@0
#define SIZE 22 // >=AB0=B0 4;O :>;8G5AB20 2K7>2>2 DC=:F88 CountIndicator 2 :>45
//+----------------------------------------------+
//| 0@0<5B@K >B@8A>2:8 25@E=53> 8=48:0B>@0 |
//+----------------------------------------------+
//---- 2 :0G5AB25 8=48:0B>@0 8A?>;L7>20= ZIGZAG
#property indicator_type20 DRAW_COLOR_ZIGZAG
//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20=K
#property indicator_color20 clrMediumVioletRed,clrMediumSeaGreen
//---- B>;I8=0 ;8=88 8=48:0B>@0 1 @02=0 4
#property indicator_width20 4
//---- >B>1@065=85 1KG59 <5B:8 8=48:0B>@0
#property indicator_label20 "Zigzag2_R"
//+----------------------------------------------+
//| E>4=K5 ?0@0<5B@K 8=48:0B>@0 |
//+----------------------------------------------+
input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; // 5@8>4 3@0D8:0 8=48:0B>@0
//---
input int ExtDepth=12;
input int ExtDeviation=5;
input int ExtBackstep=3;
input int Shift=0; // A4283 7837030 ?> 3>@87>=B0;8 2 10@0E
input double FiboRatio =1.000; //>MDD8F85=B 4><=>65=8O 2A5E D81>C@>2=59
uint FiboTotal=1; //>;8G5AB2> 4>?>;=8B5;L=KE A5:B>@>2 $81> A25@EC 8;8 A=87C
//----
input double FiboLevel1 =0.000; //7=0G5=85 D81>C@>2=O 1
input ENUM_LINE_STYLE StyleLevel1=STYLE_SOLID; //AB8;L ;8=88 D81>C@>2=O 1
input uint WidthLevel1=4; //B>;I8=0 ;8=88 D81>C@>2=O 1
input color Color_Level1 = clrDodgerBlue; //F25B D81>C@>2=O 1
//----
input double FiboLevel2=0.236; //7=0G5=85 D81>C@>2=O 2
input ENUM_LINE_STYLE StyleLevel2=STYLE_SOLID; //AB8;L ;8=88 D81>C@>2=O 2
input uint WidthLevel2=1; //B>;I8=0 ;8=88 D81>C@>2=O 2
input color Color_Level2= clrDarkViolet; //F25B D81>C@>2=O 2
//----
input double FiboLevel3 =0.382; //7=0G5=85 D81>C@>2=O 3
input ENUM_LINE_STYLE StyleLevel3=STYLE_DASH; //AB8;L ;8=88 D81>C@>2=O 3
input uint WidthLevel3=1; //B>;I8=0 ;8=88 D81>C@>2=O 3
input color Color_Level3 = clrOrange; //F25B D81>C@>2=O 3
//----
input double FiboLevel4 =0.500; //7=0G5=85 D81>C@>2=O 4
input ENUM_LINE_STYLE StyleLevel4=STYLE_SOLID; //AB8;L ;8=88 D81>C@>2=O 4
input uint WidthLevel4=2; //B>;I8=0 ;8=88 D81>C@>2=O 4
input color Color_Level4 = clrMagenta; //F25B D81>C@>2=O 4
//----
input double FiboLevel5 =0.618; //7=0G5=85 D81>C@>2=O 5
input ENUM_LINE_STYLE StyleLevel5=STYLE_DASH; //AB8;L ;8=88 D81>C@>2=O 5
input uint WidthLevel5=1; //B>;I8=0 ;8=88 D81>C@>2=O 5
input color Color_Level5 = clrBlue; //F25B D81>C@>2=O 5
//----
input double FiboLevel6=0.764; //7=0G5=85 D81>C@>2=O 6
input ENUM_LINE_STYLE StyleLevel6=STYLE_SOLID; //AB8;L ;8=88 D81>C@>2=O 6
input uint WidthLevel6=1; //B>;I8=0 ;8=88 D81>C@>2=O 6
input color Color_Level6 = clrGray; //F25B D81>C@>2=O 6
//----
input double FiboLevel7 = 1.000; //7=0G5=85 D81>C@>2=O 7
input ENUM_LINE_STYLE StyleLevel7=STYLE_SOLID; //AB8;L ;8=88 D81>C@>2=O 7
input uint WidthLevel7=4; //B>;I8=0 ;8=88 D81>C@>2=O 7
input color Color_Level7 = clrDodgerBlue; //F25B D81>C@>2=O 7
//+----------------------------------------------+
//--- >1JO2;5=85 F5;>G8A;5==KE ?5@5<5==KE =0G0;0 >BAG5B0 40==KE
int min_rates_total;
//--- >1JO2;5=85 F5;>G8A;5==KE ?5@5<5==KE 4;O E5=4;>2 8=48:0B>@>2
int Ind_Handle;
//---- <0AA82K ?5@5<5==KE 4;O ;8=89 $81>
double Values[];
color Colors[];
ENUM_LINE_STYLE Styles[];
uint Widths[];
string FiboLineNames[];
//+------------------------------------------------------------------+
//| >;CG5=85 B09<D@59<0 2 2845 AB@>:8 |
//+------------------------------------------------------------------+
string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)
{return(StringSubstr(EnumToString(timeframe),7,-1));}
//+------------------------------------------------------------------+
//| 0AA82K ?5@5<5==KE 4;O A>740=8O 8=48:0B>@=KE 1CD5@>2 |
//+------------------------------------------------------------------+
class CIndicatorsBuffers
{
public: double LineIndBuffer[];
};
//+------------------------------------------------------------------+
//| !>740=85 8=48:0B>@=KE 1CD5@>2 |
//+------------------------------------------------------------------+
CIndicatorsBuffers Ind[SIZE];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- 8=8F80;870F8O ?5@5<5==KE
min_rates_total=2;
//--- ?>;CG5=85 E5=4;0 8=48:0B>@0 Zigzag2_R_Color_Fibo_Grand_x3_Stat_Full_Arr
Ind_Handle=iCustom(Symbol(),TimeFrame,"Zigzag2_R_Color_Fibo_Grand_x3_Stat_Full_Arr",ExtDepth,ExtDeviation,ExtBackstep,0,FiboRatio,
FiboLevel1,WidthLevel1,Color_Level1,FiboLevel2,WidthLevel2,Color_Level2,FiboLevel3,WidthLevel3,Color_Level3,
FiboLevel4,WidthLevel4,Color_Level4,FiboLevel5,WidthLevel5,Color_Level5,FiboLevel6,WidthLevel6,Color_Level6,FiboLevel7,WidthLevel7,Color_Level7);
if(Ind_Handle==INVALID_HANDLE)
{
Print("5 C40;>AL ?>;CG8BL E5=4; 8=48:0B>@0 Zigzag2_R_Color_Fibo_Grand_x3_Stat_Full_Arr");
return(INIT_FAILED);
}
//--- 8=8F80;870F8O 8=48:0B>@=KE 1CD5@>2
IndInit(19,NULL,min_rates_total,Shift);
//---
IndBufferInit(19,Ind[19].LineIndBuffer,INDICATOR_DATA);
IndBufferInit(20,Ind[20].LineIndBuffer,INDICATOR_DATA);
IndBufferInit(21,Ind[21].LineIndBuffer,INDICATOR_COLOR_INDEX);
//----
ArrayResize(Values,SIZE-2);
ArrayResize(Colors,SIZE-2);
ArrayResize(Styles,SIZE-2);
ArrayResize(Widths,SIZE-2);
ArrayResize(FiboLineNames,SIZE-2);
//----
Values[0]=FiboLevel1*FiboRatio;
Values[1]=FiboLevel2*FiboRatio;
Values[2]=FiboLevel3*FiboRatio;
Values[3]=FiboLevel4*FiboRatio;
Values[4]=FiboLevel5*FiboRatio;
Values[5]=FiboLevel6*FiboRatio;
Values[6]=FiboLevel7*FiboRatio;
//----
FiboLineNames[0]="FiboLevel "+DoubleToString(100*Values[0],1);
FiboLineNames[1]="FiboLevel "+DoubleToString(100*Values[1],1);
FiboLineNames[2]="FiboLevel "+DoubleToString(100*Values[2],1);
FiboLineNames[3]="FiboLevel "+DoubleToString(100*Values[3],1);
FiboLineNames[4]="FiboLevel "+DoubleToString(100*Values[4],1);
FiboLineNames[5]="FiboLevel "+DoubleToString(100*Values[5],1);
FiboLineNames[6]="FiboLevel "+DoubleToString(100*Values[6],1);
//----
Colors[0]=Color_Level1;
Colors[1]=Color_Level2;
Colors[2]=Color_Level3;
Colors[3]=Color_Level4;
Colors[4]=Color_Level5;
Colors[5]=Color_Level6;
Colors[6]=Color_Level7;
//----
Styles[0]=StyleLevel1;
Styles[1]=StyleLevel2;
Styles[2]=StyleLevel3;
Styles[3]=StyleLevel4;
Styles[4]=StyleLevel5;
Styles[5]=StyleLevel6;
Styles[6]=StyleLevel7;
//----
Widths[0]=WidthLevel1;
Widths[1]=WidthLevel2;
Widths[2]=WidthLevel3;
Widths[3]=WidthLevel4;
Widths[4]=WidthLevel5;
Widths[5]=WidthLevel6;
Widths[6]=WidthLevel7;
for(int count=1; count<=int(1); count++)
for(int lev=1; lev<7; lev++)
{
int kkk=lev+6*(2*count-1);
Values[kkk]=Values[lev]+count;
Colors[kkk]=Colors[lev];
FiboLineNames[kkk]=FiboLineNames[lev];
Styles[kkk]=Styles[lev];
Widths[kkk]=Widths[lev];
//----
kkk=lev+6*(2*count);
Values[kkk]=-Values[7-lev]-count+1;
FiboLineNames[kkk]="FiboLevel "+DoubleToString(100*Values[kkk],1);
//Colors[kkk]=Colors[lev-1];
Colors[kkk]=Colors[7-lev];
Styles[kkk]=Styles[lev-1];
Widths[kkk]=Widths[lev-1];
}
//----
for(int numb=0; numb<int(SIZE-3); numb++)
{
string shortname=FiboLineNames[numb];
//--- A>740=85 8<5=8 4;O >B>1@065=8O 2 >B45;L=>< ?>4>:=5 8 2> 2A?;K20NI59 ?>4A:07:5
PlotIndexSetString(numb,PLOT_LABEL,shortname);
//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5
PlotIndexSetDouble(numb,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0
PlotIndexSetInteger(numb,PLOT_DRAW_BEGIN,min_rates_total);
//---- ?@52@0I5=85 48=0<8G5A:8E <0AA82>2 2 8=48:0B>@=K5 1CD5@K
SetIndexBuffer(numb,Ind[numb].LineIndBuffer,INDICATOR_DATA);
//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@0E :0: 2 B09<A5@8OE
ArraySetAsSeries(Ind[numb].LineIndBuffer,true);
//---- :>?8@>20=85 A2>9AB2 ?5@2>9 ;8=88 8=48:0B>@0 4;O 2A5E >AB0;L=KE
PlotIndexSetInteger(numb,PLOT_DRAW_TYPE,DRAW_LINE);
PlotIndexSetInteger(numb,PLOT_LINE_WIDTH,Widths[numb]);
PlotIndexSetInteger(numb,PLOT_LINE_STYLE,Styles[numb]);
PlotIndexSetInteger(numb,PLOT_COLOR_INDEXES,1);
PlotIndexSetInteger(numb,PLOT_LINE_COLOR,0,Colors[numb]);
//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8 =0 Shift
PlotIndexSetInteger(numb,PLOT_SHIFT,Shift);
//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0
PlotIndexSetInteger(numb,PLOT_SHOW_DATA,false);
}
//--- A>740=85 8<5=8 4;O >B>1@065=8O 2 >B45;L=>< ?>4>:=5 8 2> 2A?;K20NI59 ?>4A:07:5
string shortname;
StringConcatenate(shortname,INDICATOR_NAME,"(",GetStringTimeframe(TimeFrame),")");
//---
IndicatorSetString(INDICATOR_SHORTNAME,shortname);
//--- >?@545;5=85 B>G=>AB8 >B>1@065=8O 7=0G5=89 8=48:0B>@0
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- 7025@H5=85 8=8F80;870F88
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//----
Comment("");
//----
ChartRedraw(0);
}
//+------------------------------------------------------------------+
//| Custom iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, // :>;8G5AB2> 8AB>@88 2 10@0E =0 B5:CI5< B8:5
const int prev_calculated,// :>;8G5AB2> 8AB>@88 2 10@0E =0 ?@54K4CI5< B8:5
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//--- ?@>25@:0 ?5@8>4>2 3@0D8:>2 =0 :>@@5:B=>ABL
if(!TimeFramesCheck(INDICATOR_NAME,TimeFrame)) return(RESET);
//--- ?@>25@:0 :>;8G5AB20 10@>2 =0 4>AB0B>G=>ABL 4;O @0AG5B0
if(rates_total<min_rates_total) return(RESET);
if(BarsCalculated(Ind_Handle)<Bars(Symbol(),TimeFrame)) return(prev_calculated);
//--- 8=45:A0F8O M;5<5=B>2 2 <0AA820E :0: 2 B09<A5@8OE
ArraySetAsSeries(time,true);
int limit,prev_calculated_xxx;
//---- @0AG5B AB0@B>2>3> =><5@0 limit 4;O F8:;0 ?5@5AG5B0 10@>2
if(prev_calculated>rates_total || prev_calculated<=0)// ?@>25@:0 =0 ?5@2K9 AB0@B @0AG5B0 8=48:0B>@0
{
limit=rates_total-min_rates_total-1; // AB0@B>2K9 =><5@ 4;O @0AG5B0 2A5E 10@>2
prev_calculated_xxx=prev_calculated;
}
else
{
limit=rates_total-prev_calculated; // AB0@B>2K9 =><5@ 4;O @0AG5B0 =>2KE 10@>2
//---- >1JO2;5=8O ;>:0;L=KE ?5@5<5==KE
int bar1,bar2,sign;
double price1,price2;
//----
bar1=FindFirstExtremum(limit,rates_total,Ind[20].LineIndBuffer,Ind[19].LineIndBuffer,sign,price1);
bar1=FindSecondExtremum(sign,bar1,rates_total,Ind[20].LineIndBuffer,Ind[19].LineIndBuffer,sign,price1);
bar2=FindSecondExtremum(sign,bar1,rates_total,Ind[20].LineIndBuffer,Ind[19].LineIndBuffer,sign,price2);
prev_calculated_xxx=rates_total-limit-bar2;
limit=rates_total-prev_calculated_xxx;
}
//---
for(int numb=0; numb<int(SIZE-3); numb++)
if(!CountIndicator(numb,NULL,TimeFrame,Ind_Handle,numb,Ind[numb].LineIndBuffer,time,rates_total,prev_calculated_xxx,min_rates_total)) return(RESET);
if(!CountIndicator(19,NULL,TimeFrame,Ind_Handle,19,Ind[19].LineIndBuffer,time,rates_total,prev_calculated_xxx,min_rates_total)) return(RESET);
if(!CountIndicator(20,NULL,TimeFrame,Ind_Handle,20,Ind[20].LineIndBuffer,time,rates_total,prev_calculated_xxx,min_rates_total)) return(RESET);
if(!CountIndicator(21,NULL,TimeFrame,Ind_Handle,21,Ind[21].LineIndBuffer,time,rates_total,prev_calculated_xxx,min_rates_total)) return(RESET);
//---
for(int bar=limit; bar>=0 && !IsStopped(); bar--)
{
for(int numb=0; numb<int(SIZE-3); numb++)
{
if(Ind[numb].LineIndBuffer[bar+1]!=Ind[numb].LineIndBuffer[bar]&&Ind[numb].LineIndBuffer[bar]!=EMPTY_VALUE)
{
Ind[numb].LineIndBuffer[bar+1]=EMPTY_VALUE;
}
}
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+
//| =8F80;870F8O 8=48:0B>@=>3> 1CD5@0 |
//+------------------------------------------------------------------+
void IndBufferInit(int Number,double &Buffer[],ENUM_INDEXBUFFER_TYPE data_type)
{
//--- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@
SetIndexBuffer(Number,Buffer,data_type);
//--- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88
ArraySetAsSeries(Buffer,true);
//---
}
//+------------------------------------------------------------------+
//| =8F80;870F8O 8=48:0B>@=>3> 1CD5@0 |
//+------------------------------------------------------------------+
void IndInit(int Number,double Empty_Value,int Draw_Begin,int nShift)
{
//--- >ACI5AB2;5=85 A42830 =0G0;0 >BAG5B0 >B@8A>2:8 8=48:0B>@0
PlotIndexSetInteger(Number,PLOT_DRAW_BEGIN,Draw_Begin);
//--- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5
PlotIndexSetDouble(Number,PLOT_EMPTY_VALUE,Empty_Value);
//---- :>?8@>20=85 A2>9AB2 ?5@2>9 ;8=88 8=48:0B>@0 4;O 2A5E >AB0;L=KE
//PlotIndexSetInteger(Number,PLOT_DRAW_TYPE,DRAW_ARROW);
//--- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8 =0 Shift
PlotIndexSetInteger(Number,PLOT_SHIFT,nShift);
}
//+------------------------------------------------------------------+
//| CountIndicator |
//+------------------------------------------------------------------+
bool CountIndicator(uint Numb, // ><5@ DC=:F88 CountLine ?> A?8A:C 2 :>45 8=48:0B>@0 (AB0@B>2K9 =><5@ - 0)
string Symb, // !8<2>; 3@0D8:0
ENUM_TIMEFRAMES TFrame, // 5@8>4 3@0D8:0
int IndHandle, // %5=4; >1@010BK205<>3> 8=48:0B>@0
uint BuffNumb, // ><5@ 1CD5@0 >1@010BK205<>3> 8=48:0B>@0
double& IndBuf[], // @85<=K9 1CD5@ 8=48:0B>@0
const datetime& nTime[], // "09<A5@8O 2@5<5=8
const int Rates_Total, // :>;8G5AB2> 8AB>@88 2 10@0E =0 B5:CI5< B8:5
const int Prev_Calculated,// :>;8G5AB2> 8AB>@88 2 10@0E =0 ?@54K4CI5< B8:5
const int Min_Rates_Total)// <8=8<0;L=>5 :>;8G5AB2> 8AB>@88 2 10@0E 4;O @0AG5B0
{
//---
static int LastCountBar[SIZE];
datetime IndTime[1];
int limit;
//--- @0AG5BK =5>1E>48<>3> :>;8G5AB20 :>?8@C5<KE 40==KE
//--- 8 AB0@B>2>3> =><5@0 limit 4;O F8:;0 ?5@5AG5B0 10@>2
if(Prev_Calculated>Rates_Total || Prev_Calculated<=0)// ?@>25@:0 =0 ?5@2K9 AB0@B @0AG5B0 8=48:0B>@0
{
limit=Rates_Total-Min_Rates_Total-1; // AB0@B>2K9 =><5@ 4;O @0AG5B0 2A5E 10@>2
LastCountBar[Numb]=limit;
}
else limit=LastCountBar[Numb]+Rates_Total-Prev_Calculated; // AB0@B>2K9 =><5@ 4;O @0AG5B0 =>2KE 10@>2
//--- >A=>2=>9 F8:; @0AG5B0 8=48:0B>@0
for(int bar=limit; bar>=0 && !IsStopped(); bar--)
{
//--- :>?8@C5< 2=>2L ?>O282H85AO 40==K5 2 <0AA82 IndTime
if(CopyTime(Symbol(),TFrame,nTime[bar],1,IndTime)<=0) return(false);
//---
if(nTime[bar]>=IndTime[0] && nTime[bar+1]<IndTime[0])
{
LastCountBar[Numb]=bar;
double Arr[1];
//--- :>?8@C5< 2=>2L ?>O282H85AO 40==K5 2 <0AA82K
if(CopyBuffer(IndHandle,BuffNumb,nTime[bar],1,Arr)<=0) return(false);
IndBuf[bar]=Arr[0];
}
else
{
IndBuf[bar]=IndBuf[bar+1];
}
}
//---
return(true);
}
//+------------------------------------------------------------------+
//| TimeFramesCheck() |
//+------------------------------------------------------------------+
bool TimeFramesCheck(string IndName,
ENUM_TIMEFRAMES TFrame) //5@8>4 3@0D8:0 8=48:0B>@0 (B09<D@59<)
{
//--- ?@>25@:0 ?5@8>4>2 3@0D8:>2 =0 :>@@5:B=>ABL
if(TFrame<Period() && TFrame!=PERIOD_CURRENT)
{
Print("5@8>4 3@0D8:0 4;O 8=48:0B>@0 "+IndName+" =5 <>65B 1KBL <5=LH5 ?5@8>40 B5:CI53> 3@0D8:0!");
Print("!;54C5B 87<5=8BL 2E>4=K5 ?0@0<5B@K 8=48:0B>@0!");
return(false);
}
//---
return(true);
}
//+------------------------------------------------------------------+
//| >8A: A0<>9 ?5@2>9 25@H8=K 837030 2 1CD5@0E B09<A5@8OE |
//+------------------------------------------------------------------+
int FindFirstExtremum(int &StartPos,int Rates_total,double &UpArray[],double &DnArray[],int &Sign,double &Extremum)
{
//----
if(StartPos>=Rates_total)StartPos=Rates_total-1;
for(int bar=StartPos; bar<Rates_total; bar++)
{
if(UpArray[bar]!=0.0 && UpArray[bar]!=EMPTY_VALUE)
{
Sign=+1;
Extremum=UpArray[bar];
return(bar);
break;
}
if(DnArray[bar]!=0.0 && DnArray[bar]!=EMPTY_VALUE)
{
Sign=-1;
Extremum=DnArray[bar];
return(bar);
break;
}
}
//----
return(-1);
}
//+------------------------------------------------------------------+
//| >8A: 2B>@>9 25@H8=K 837030 2 1CD5@0E B09<A5@8OE |
//+------------------------------------------------------------------+
int FindSecondExtremum(int Direct,int &StartPos,int Rates_total,double &UpArray[],double &DnArray[],int &Sign,double &Extremum)
{
//----
if(StartPos>=Rates_total) StartPos=Rates_total-1;
if(Direct==-1)
for(int bar=StartPos; bar<Rates_total; bar++)
{
if(UpArray[bar]!=0.0 && UpArray[bar]!=EMPTY_VALUE)
{
Sign=+1;
Extremum=UpArray[bar];
return(bar);
break;
}
}
if(Direct==+1)
for(int bar=StartPos; bar<Rates_total; bar++)
{
if(DnArray[bar]!=0.0 && DnArray[bar]!=EMPTY_VALUE)
{
Sign=-1;
Extremum=DnArray[bar];
return(bar);
break;
}
}
//----
return(-1);
}
//+------------------------------------------------------------------+
Comments