كود:
//+------------------------------------------------------------------+
#property copyright " aa"
#property link "[email protected]"
#property description "tester"
#property strict
//--- input parameters
input int InpBandsPeriod=20;
input int InpBandsShift=0;
input double InpBandsDeviations=2.0;
input int InpMAPeriod=5;
void draw_lines(string name, int C1, double P1, int C0, double P0, color clr, int style, int width)
{ datetime timex1=Time[C0];
if(C0<=0)timex1=Time[C1]+60*PERIOD_D1+60*Period();
ObjectDelete(name);
ObjectCreate( 0,name,OBJ_TREND,0,Time[C1],P1,timex1,P0);
ObjectSetInteger( 0,name,OBJPROP_COLOR,clr);
ObjectSetInteger( 0,name,OBJPROP_STYLE,style);
ObjectSetInteger( 0,name,OBJPROP_RAY_RIGHT,FALSE);
ObjectSetInteger( 0,name,OBJPROP_SELECTABLE,FALSE);
ObjectSetInteger( 0,name,OBJPROP_SELECTED,FALSE);
ObjectSetInteger( 0,name,OBJPROP_WIDTH,width);
ObjectSetInteger( 0,name,OBJPROP_HIDDEN,TRUE);
ObjectSetString( 0,name,OBJPROP_TOOLTIP,TimeToString(Time[C0],TIME_MINUTES));
}
//+------------------------------------------------------------------+
//| Testing Criteria |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
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[])
{
int tt=Bars-20;
for( int i=tt-1;i>=0;i--)
{
double MA5H=iMA(NULL,0,InpMAPeriod,0,MODE_LWMA,PRICE_HIGH,i+1);
double MA5H1=iMA(NULL,0,InpMAPeriod,0,MODE_LWMA,PRICE_HIGH,i);
double MA5L=iMA(NULL,0,InpMAPeriod,0,MODE_LWMA,PRICE_LOW,i+1);
double MA5L1=iMA(NULL,0,InpMAPeriod,0,MODE_LWMA,PRICE_LOW,i);
double UP_BAND1=iBands(NULL,0,InpBandsPeriod,InpBandsDeviations,InpBandsShift,PRICE_CLOSE,MODE_UPPER,i+1);
double UP_BAND2=iBands(NULL,0,InpBandsPeriod,InpBandsDeviations,InpBandsShift,PRICE_CLOSE,MODE_UPPER,i);
double DN_BAND1=iBands(NULL,0,InpBandsPeriod,InpBandsDeviations,InpBandsShift,PRICE_CLOSE,MODE_LOWER,i+1);
double DN_BAND2=iBands(NULL,0,InpBandsPeriod,InpBandsDeviations,InpBandsShift,PRICE_CLOSE,MODE_LOWER,i);
double C0=Close[i];
double O0=Open[i];
double C1=Close[i+1];
double O1=Open[i+1];
if(DN_BAND2>MA5L1 && O0<DN_BAND2)
{
if(C0>DN_BAND2)
{
draw_lines("XX/RSI0_"+i, i, Close[i], i, Close[i], clrBlue, 1, 11);
}
}
else if(UP_BAND2<MA5H1 && O0>UP_BAND2)
{
if(C0<UP_BAND2)
{
draw_lines("XX/RSI0_"+i, i, Close[i], i, Close[i], clrRed, 1, 11);
}
}
}
return(rates_total);
}
void deinit() // Special function deinit()
{
ObjectsDeleteAll(0); // Exit deinit()
}