كود PHP:
#property copyright "Copyright © 2007, Waddah Attar"
#property link waddahattar@hotmail.com
//----
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 Green
#property indicator_color6 Blue
#property indicator_color7 Orange
#property indicator_color8 Orange
extern bool BackTest=false;
extern bool DrawMonth=true;
extern bool DrawWeek=true;
extern bool DrawDay=true;
extern bool DrawH4=false;
//---- buffers
double P1Buffer[];
double P2Buffer[];
double P3Buffer[];
double P4Buffer[];
double P5Buffer[];
double P6Buffer[];
double P7Buffer[];
double P8Buffer[];
//----
int levelPeriod1 = PERIOD_D1;
int levelPeriod2 = PERIOD_H4;
int levelPeriod3 = PERIOD_W1;
int levelPeriod4 = PERIOD_MN1;
bool FixSunday;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, P1Buffer);
SetIndexBuffer(1, P2Buffer);
SetIndexBuffer(2, P3Buffer);
SetIndexBuffer(3, P4Buffer);
SetIndexBuffer(4, P5Buffer);
SetIndexBuffer(5, P6Buffer);
SetIndexBuffer(6, P7Buffer);
SetIndexBuffer(7, P8Buffer);
//----
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 3);
SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 1);
SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 3);
SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 4);
SetIndexStyle(7, DRAW_LINE, STYLE_SOLID, 4);
//----
Comment("Strong Level By eng.Waddah Attar ");
FixSunday=false;
for(int i = 0; i <7; i++)
{
if (TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,i))==0)
{
FixSunday=true;
}
}
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
// تنظيف الشارت من الكائنات الرسومية التي ولدها هذا المؤشر وهي عملية ضرورية لمؤشر احترافي
// والحذف يكون طبعا فقط للكائنات الخاصة به وليس حذف عام
ObjectDelete("level1");
ObjectDelete("txtlevel1");
ObjectDelete("level2");
ObjectDelete("txtlevel2");
ObjectDelete("level3");
ObjectDelete("txtlevel3");
ObjectDelete("level4");
ObjectDelete("txtlevel4");
ObjectDelete("level5");
ObjectDelete("txtlevel5");
ObjectDelete("level6");
ObjectDelete("txtlevel6");
ObjectDelete("level7");
ObjectDelete("txtlevel7");
ObjectDelete("level8");
ObjectDelete("txtlevel8");
//----
Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
if(DrawDay) DrawPeriod1();
if(DrawH4) DrawPeriod2();
if(DrawWeek) DrawPeriod3();
if(DrawMonth) DrawPeriod4();
if (BackTest==false)
{
for(int i=1; i < Bars; i++)
{
P1Buffer[i]=P1Buffer[0];
P2Buffer[i]=P2Buffer[0];
P3Buffer[i]=P3Buffer[0];
P4Buffer[i]=P4Buffer[0];
P5Buffer[i]=P5Buffer[0];
P6Buffer[i]=P6Buffer[0];
P7Buffer[i]=P7Buffer[0];
P8Buffer[i]=P8Buffer[0];
}
}
return(0);
}
int DrawPeriod1()
{
int i, ii, counted_bars = IndicatorCounted();
double c1, c2, dc;
string TrendType;
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
int limit = Bars - counted_bars;
//----
for(i = limit - 1; i >= 0; i--)
{
ii = iBarShift(Symbol(), levelPeriod1, Time[i],true);
if (TimeDayOfWeek(Time[i])==1 && FixSunday==true)
{
ii=ii+1;
}
if(ii != -1)
{
c1 = iClose(Symbol(), levelPeriod1, ii + 1);
c2 = iClose(Symbol(), levelPeriod1, ii + 2);
//----
dc = c1 - c2;
//----
if(dc == 0)
{
c2 = iClose(Symbol(), levelPeriod1, ii + 3);
}
//----
dc = c1 - c2;
//----
if(dc == 0)
{
dc = c1;
}
//----
P1Buffer[i] = c1-dc;
P4Buffer[i] = c1+dc;
if (P1Buffer[i]<P4Buffer[i])
{
TrendType="Day Up ";
}
else
{
TrendType="Day Down ";
}
// عملت وظيفتين تختصر الكثير من كتابة الكود لوضع كائن سعري وكائن نصي
SetPrice("level1", Time[i],P1Buffer[i], Red);
SetText("txtlevel1", TrendType, Time[i], P1Buffer[i], Red);
SetPrice("level4", Time[i],P4Buffer[i], Red);
SetText("txtlevel4", TrendType, Time[i], P4Buffer[i], Red);
//----
}
}
//----
return(0);
}
int DrawPeriod2()
{
int i, ii, counted_bars = IndicatorCounted();
double c1, c2, dc;
string TrendType;
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
int limit = Bars - counted_bars;
//----
for(i = limit - 1; i >= 0; i--)
{
ii = iBarShift(Symbol(), levelPeriod2, Time[i],true);
if(ii != -1)
{
c1 = iClose(Symbol(), levelPeriod2, ii + 1);
c2 = iClose(Symbol(), levelPeriod2, ii + 2);
//----
dc = c1 - c2;
//----
if(dc == 0)
{
c2 = iClose(Symbol(), levelPeriod2, ii + 3);
}
//----
dc = c1 - c2;
//----
if(dc == 0)
{
dc = c1;
}
//----
P2Buffer[i] = c1-dc;
P5Buffer[i] = c1+dc;
if (P2Buffer[i]<P5Buffer[i])
{
TrendType="H4 Up ";
}
else
{
TrendType="H4 Down ";
}
SetPrice("level2", Time[i],P2Buffer[i], Green);
SetText("txtlevel2", TrendType, Time[i], P2Buffer[i], Green);
SetPrice("level5", Time[i],P5Buffer[i], Green);
SetText("txtlevel5", TrendType, Time[i], P5Buffer[i], Green);
//----
}
}
//----
return(0);
}
int DrawPeriod3()
{
int i, ii, counted_bars = IndicatorCounted();
double c1, c2, dc;
string TrendType;
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
int limit = Bars - counted_bars;
//----
for(i = limit - 1; i >= 0; i--)
{
ii = iBarShift(Symbol(), levelPeriod3, Time[i],true);
if(ii != -1)
{
c1 = iClose(Symbol(),