رمز:
extern bool Alert.=true;
extern int Count=2;
extern int Range=20;
int fontsize=10;
double YL,YH;
int LastTime1 = 1;
int LastTime2 = 1;
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("YLowLb");
ObjectDelete("YLowLn");
ObjectDelete("YHighLb");
ObjectDelete("YHighLn");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//---- exit if period is greater than H1 charts
if(Period() > 60)
{
Print("Error - Chart period is greater than H1 Chart.");
return(-1); // then exit
}
int limit, i;
//---- indicator calculation
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
// if(counted_bars>0) counted_bars--;
limit=(Bars-counted_bars)-1;
limit = Bars-1;
int dshift= iBarShift(NULL,PERIOD_D1,Time[i]);
YL= iLow(NULL,PERIOD_D1,dshift+1);
YH= iHigh(NULL,PERIOD_D1,dshift+1);
//----- Lines
if(ObjectFind("YLowLn") != 0)
{
ObjectCreate("YLowLn", OBJ_HLINE, 0, 0, 0);
ObjectSet("YLowLn", OBJPROP_PRICE1, YL);
ObjectSet("YLowLn", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("YLowLn", OBJPROP_COLOR, White);
ObjectCreate("YLowLb", OBJ_TEXT, 0, Time[7], 0);
ObjectSet("YLowLb", OBJPROP_PRICE1, YL);
ObjectSetText("YLowLb", "Yesterday Low", 12, "Arial", White);
ObjectCreate("YHighLn", OBJ_HLINE, 0, Time[7], 0);
ObjectSet("YHighLn", OBJPROP_PRICE1, YH);
ObjectSet("YHighLn", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("YHighLn", OBJPROP_COLOR, White);
ObjectCreate("YHighLb", OBJ_TEXT, 0, Time[7], 0);
ObjectSet("YHighLb", OBJPROP_PRICE1, YH);
ObjectSetText("YHighLb", "Yesterday High", 12, "Arial", White);
}
else
{
ObjectMove("YLowLn", 0, Time[7], YL);
ObjectMove("YHighLn", 0, Time[7], YH);
}
if(Alert.==true)
{
double val1 = ObjectGet( "YLowLn", OBJPROP_PRICE1);
if (Bid-Range*Point <= val1 && Bid+Range*Point >= val1 && LastTime1 < (Count+1))
{Alert (Symbol()," ",Period()," Yesterday Low ",Bid);}LastTime1++;
double val2 = ObjectGet( "YHighLn", OBJPROP_PRICE1);
if (Bid-Range*Point <= val2 && Bid+Range*Point >= val2 && LastTime2 < (Count+1))
{Alert (Symbol()," ",Period()," Yesterday High ",Bid);}LastTime2++;
}
return(0);
}