Одна из версий канала ДиНаполи One version of the channel DiNapoliИндикатор под МТ4 Indicator for MT4 //+------------------------------------------------------------------------------------+ //+----------------------------------------------- -------------------------------------+
//| Din_fibo_high.mq4 | / / | Din_fibo_high.mq4 |
//| unknown author, get from kaizer, conversed by Rosh | / / | Unknown author, get from kaizer, conversed by Rosh |
//| link to kaizer: http://forum.alpari-idc.ru/profile.php?mode=viewprofile&u=4196161 | / / | Link to kaizer: http://forum.alpari-idc.ru/profile.php?mode=viewprofile&u=4196161 |
//| http://forexsystems.ru/phpBB/index.php| / / | Http://forexsystems.ru/phpBB/index.php |
//+------------------------------------------------------------------------------------+ //+----------------------------------------------- -------------------------------------+
#property copyright "unknown author, get from kaizer, conversed by Rosh" # property copyright "unknown author, get from kaizer, conversed by Rosh"
#property link "http://forexsystems.ru/phpBB/index.php" # property link "http://forexsystems.ru/phpBB/index.php"
#property indicator_chart_window # property indicator_chart_window
#property indicator_buffers 2 # property indicator_buffers 2
#property indicator_color1 Blue # property indicator_color1 Blue
#property indicator_color2 Yellow # property indicator_color2 Yellow
//---- input parameters //---- Input parameters
extern int Ch_Period=3; extern int Ch_Period = 3;
extern double Ratio=0.786; extern double Ratio = 0.786;
extern bool SetAllBars=false; extern bool SetAllBars = false;
//---- buffers //---- Buffers
double ExtMapBuffer1[]; double ExtMapBuffer1 [];
double ExtMapBuffer2[]; double ExtMapBuffer2 [];
double tvBuffer[]; double tvBuffer [];
int hh,ll,first,counterPeriod; int hh, ll, first, counterPeriod;
double tv,MaH,MaL; double tv, MaH, MaL;
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
//| Проверим - разделитель диапазона или нет | / / | Check - separator band or not |
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
bool isDelimeter(int _Period, int _shift) bool isDelimeter (int _Period, int _shift)
{ (
bool result=false; Bool result = false;
//----
switch (_Period) Switch (_Period)
{ (
case 5:result=(TimeMinute(Time[_shift])==0)&&(TimeHour(Time[_shift])==0); break; case 5: result = (TimeMinute (Time [_shift]) == 0) & & (TimeHour (Time [_shift]) == 0); break;
case 15:result=(TimeMinute(Time[_shift])==0)&&(TimeHour(Time[_shift])==0); break; case 15: result = (TimeMinute (Time [_shift]) == 0) & & (TimeHour (Time [_shift]) == 0); break;
case 30:result=(TimeMinute(Time[_shift])==0)&&(TimeHour(Time[_shift])==0); break; case 30: result = (TimeMinute (Time [_shift]) == 0) & & (TimeHour (Time [_shift]) == 0); break;
case 60:result=(TimeMinute(Time[_shift])==0)&&(TimeHour(Time[_shift])==0); break; case 60: result = (TimeMinute (Time [_shift]) == 0) & & (TimeHour (Time [_shift]) == 0); break;
case 240:result=(TimeDayOfWeek(Time[_shift])==1)&&(TimeHour(Time[_shift])==0); break; case 240: result = (TimeDayOfWeek (Time [_shift]) == 1) & & (TimeHour (Time [_shift]) == 0); break;
case 1440:result=(TimeDay(Time[_shift])==1)||((TimeDay(Time[_shift])==2 && TimeDay(Time[_shift+1])!=1))||((TimeDay(Time[_shift])==3 && TimeDay(Time[_shift+1])!=2)); break; case 1440: result = (TimeDay (Time [_shift]) == 1 )||(( TimeDay (Time [_shift]) == 2 & & TimeDay (Time [_shift +1])! = 1 ))||(( TimeDay (Time [_shift]) == 3 & & TimeDay (Time [_shift +1])! = 2)); break;
case 10080:result=TimeDay(Time[_shift])<=7 && TimeMonth(Time[_shift])==1; break; case 10080: result = TimeDay (Time [_shift]) <= 7 & & TimeMonth (Time [_shift]) == 1; break;
default: Print("Недопустимый период!!!"); default: Print ( "Invalid time !!!");
} )
//----
return(result); Return (result);
} )
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
//| Установим MaH и MaL на границе диапазона | / / | Install MaH and on the border of the range MaL |
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
void SetHnL(int _shift) void SetHnL (int _shift)
{ (
//----
int i=_shift+1; Int i = _shift +1;
counterPeriod=0; CounterPeriod = 0;
while (counterPeriod While (counterPeriod
{ (
while (tvBuffer[i]==0.0 && i While (tvBuffer [i] == 0.0 & & i
counterPeriod++; CounterPeriod + +;
i++; I + +;
} )
i--; I -;
hh=Highest(NULL,0,MODE_HIGH,i-_shift,_shift+1); Hh = Highest (NULL, 0, MODE_HIGH, i-_shift, _shift +1);
ll=Lowest(NULL,0,MODE_LOW,i-_shift,_shift+1); Ll = Lowest (NULL, 0, MODE_LOW, i-_shift, _shift +1);
tv=NormalizeDouble((High[hh]+Low[ll]+Close[_shift+1])/3.0,Digits); tv = NormalizeDouble ((High [hh] + Low [ll] + Close [_shift +1]) / 3.0, Digits);
MaH=tv+NormalizeDouble((High[hh]-Low[ll])/2.0*Ratio,Digits); MaH = tv + NormalizeDouble ((High [hh]-Low [ll]) / 2.0 * Ratio, Digits);
MaL=tv-NormalizeDouble((High[hh]-Low[ll])/2.0*Ratio,Digits); MaL = tv-NormalizeDouble ((High [hh]-Low [ll]) / 2.0 * Ratio, Digits);
tvBuffer[_shift]=tv; TvBuffer [_shift] = tv;
ExtMapBuffer1[_shift]=MaH; ExtMapBuffer1 [_shift] = MaH;
ExtMapBuffer2[_shift]=MaL; ExtMapBuffer2 [_shift] = MaL;
SetMovingHnL(i, _shift); SetMovingHnL (i, _shift);
//----
return; Return;
} )
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
//| Установим MaH и MaL внутри диапазона | / / | Install MaH and MaL within the range |
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
void SetMovingHnL(int _DelimeterBar,int CurBar) void SetMovingHnL (int _DelimeterBar, int CurBar)
{ (
double delta; Double delta;
//----
delta=(tvBuffer[_DelimeterBar]-tvBuffer[CurBar])/(_DelimeterBar-CurBar); delta = (tvBuffer [_DelimeterBar]-tvBuffer [CurBar ])/(_ DelimeterBar-CurBar);
//----
return; Return;
} )
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
//| Установим MaH и MaL на правом краю | / / | Install MaH MaL and on the right side of |
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
void SetValuesNullBar(int _shift) void SetValuesNullBar (int _shift)
{ (
//----
int i=_shift; Int i = _shift;
while (tvBuffer[i]==0.0) i++; While (tvBuffer [i] == 0.0) i + +;
for (int j=i-1;j>_shift;j--) For (int j = i-1; j> _shift; j -)
{ (
ExtMapBuffer1[j]=0.0; ExtMapBuffer1 [j] = 0.0;
ExtMapBuffer2[j]=0.0; ExtMapBuffer2 [j] = 0.0;
} )
i=_shift; I = _shift;
counterPeriod=0; CounterPeriod = 0;
while (counterPeriod While (counterPeriod
{ (
while (tvBuffer[i]==0.0 && i While (tvBuffer [i] == 0.0 & & i
counterPeriod++; CounterPeriod + +;
i++; I + +;
} )
i--; I -;
hh=Highest(NULL,0,MODE_HIGH,i-_shift,_shift); Hh = Highest (NULL, 0, MODE_HIGH, i-_shift, _shift);
ll=Lowest(NULL,0,MODE_LOW,i-_shift,_shift); Ll = Lowest (NULL, 0, MODE_LOW, i-_shift, _shift);
tv=NormalizeDouble((High[hh]+Low[ll]+Close[_shift])/3.0,Digits); tv = NormalizeDouble ((High [hh] + Low [ll] + Close [_shift]) / 3.0, Digits);
MaH=tv+NormalizeDouble((High[hh]-Low[ll])/2.0*Ratio,Digits); MaH = tv + NormalizeDouble ((High [hh]-Low [ll]) / 2.0 * Ratio, Digits);
MaL=tv-NormalizeDouble((High[hh]-Low[ll])/2.0*Ratio,Digits); MaL = tv-NormalizeDouble ((High [hh]-Low [ll]) / 2.0 * Ratio, Digits);
ExtMapBuffer1[_shift]=MaH; ExtMapBuffer1 [_shift] = MaH;
ExtMapBuffer2[_shift]=MaL; ExtMapBuffer2 [_shift] = MaL;
//SetMovingHnL(j, _shift); / / SetMovingHnL (j, _shift);
//----
return; Return;
}//-------------------------------------------------------------------+ }//----------------------------------------------- --------------------+
//| Custom indicator initialization function | / / | Custom indicator initialization function |
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
int init() int init ()
{ (
//---- indicators //---- Indicators
IndicatorBuffers(3); IndicatorBuffers (3);
if (SetAllBars) If (SetAllBars)
{ (
SetIndexStyle(0,DRAW_LINE); SetIndexStyle (0, DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1); SetIndexBuffer (0, ExtMapBuffer1);
SetIndexLabel(0,"MaH"); SetIndexLabel (0, "MaH");
SetIndexEmptyValue(0,0.0); SetIndexEmptyValue (0,0.0);
SetIndexStyle(1,DRAW_LINE); SetIndexStyle (1, DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2); SetIndexBuffer (1, ExtMapBuffer2);
SetIndexLabel(1,"MaL"); SetIndexLabel (1, "MaL");
SetIndexEmptyValue(1,0.0); SetIndexEmptyValue (1,0.0);
} )
else Else
{ (
SetIndexStyle(0,DRAW_SECTION); SetIndexStyle (0, DRAW_SECTION);
SetIndexBuffer(0,ExtMapBuffer1); SetIndexBuffer (0, ExtMapBuffer1);
SetIndexLabel(0,"MaH"); SetIndexLabel (0, "MaH");
SetIndexEmptyValue(0,0.0); SetIndexEmptyValue (0,0.0);
SetIndexStyle(1,DRAW_SECTION); SetIndexStyle (1, DRAW_SECTION);
SetIndexBuffer(1,ExtMapBuffer2); SetIndexBuffer (1, ExtMapBuffer2);
SetIndexLabel(1,"MaL"); SetIndexLabel (1, "MaL");
SetIndexEmptyValue(1,0.0); SetIndexEmptyValue (1,0.0);
} )
SetIndexBuffer(2,tvBuffer); SetIndexBuffer (2, tvBuffer);
SetIndexEmptyValue(2,0.0); SetIndexEmptyValue (2,0.0);
//----
return(0); Return (0);
} )
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
//| Custor indicator deinitialization function | / / | Custor indicator deinitialization function |
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
int deinit() int deinit ()
{ (
//----
//----
return(0); Return (0);
} )
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
//| Custom indicator iteration function | / / | Custom indicator iteration function |
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+
int start() int start ()
{ (
int counted_bars=IndicatorCounted(); Int counted_bars = IndicatorCounted ();
int cnt,limit; Int cnt, limit;
//----
if (Period()==10080) return; If (Period () == 10080) return;
if (counted_bars<0)> If (counted_bars <0)>
if (counted_bars>0) limit=Bars-counted_bars; If (counted_bars> 0) limit = Bars-counted_bars;
if (counted_bars==0) If (counted_bars == 0)
{ (
// найти первый и второй разделитель и установить limit / / Find the first and second divider and set the limit
cnt=Bars-1; Cnt = Bars-1;
while (!isDelimeter(Period(),cnt)) cnt--; While (! IsDelimeter (Period (), cnt)) cnt -;
first=cnt; First = cnt;
cnt--; Cnt -;
counterPeriod=0; CounterPeriod = 0;
while (counterPeriod While (counterPeriod
{ (
while (!isDelimeter(Period(),cnt)) cnt--; While (! IsDelimeter (Period (), cnt)) cnt -;
cnt--; Cnt -;
counterPeriod++; CounterPeriod + +;
} )
cnt++; Cnt + +;
hh=Highest(NULL,0,MODE_HIGH,first-cnt,cnt+1); hh = Highest (NULL, 0, MODE_HIGH, first-cnt, cnt +1);
ll=Lowest(NULL,0,MODE_LOW,first-cnt,cnt+1); Ll = Lowest (NULL, 0, MODE_LOW, first-cnt, cnt +1);
tv=NormalizeDouble((High[hh]+Low[ll]+Close[cnt+1])/3.0,Digits); tv = NormalizeDouble ((High [hh] + Low [ll] + Close [cnt +1]) / 3.0, Digits);
MaH=tv+NormalizeDouble((High[hh]-Low[ll])/2.0*Ratio,Digits); MaH = tv + NormalizeDouble ((High [hh]-Low [ll]) / 2.0 * Ratio, Digits);
MaL=tv-NormalizeDouble((High[hh]-Low[ll])/2.0*Ratio,Digits); MaL = tv-NormalizeDouble ((High [hh]-Low [ll]) / 2.0 * Ratio, Digits);
tvBuffer[cnt]=tv; TvBuffer [cnt] = tv;
ExtMapBuffer1[cnt]=MaH; ExtMapBuffer1 [cnt] = MaH;
ExtMapBuffer2[cnt]=MaL; ExtMapBuffer2 [cnt] = MaL;
limit=cnt-1; Limit = cnt-1;
} )
//----
for (int shift=limit;shift>=0;shift--) For (int shift = limit; shift> = 0; shift -)
{ (
if (isDelimeter(Period(),shift)) SetHnL(shift);// else SetMovingHnL(shift); if (isDelimeter (Period (), shift)) SetHnL (shift); / / else SetMovingHnL (shift);
if (shift==0) SetValuesNullBar(shift); If (shift == 0) SetValuesNullBar (shift);
} )
return(0); Return (0);
} )
//+------------------------------------------------------------------+ //+----------------------------------------------- -------------------+