|
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
double CrossUp[];
double CrossDown[];
extern int Len = 26;
extern int ma2=480;
extern int ma3=960;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, i, counter;
double t1,t11,t2,t3;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i = 1; i <= limit; i++)
{
counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10.0;
t1 =iRSI(NULL, 0, Len, PRICE_CLOSE, i);
t11 =iRSI(NULL, 0, Len, PRICE_CLOSE, i+1);
t2 =iMA( NULL, 0, ma2, 0, MODE_EMA, 0, i);
t3 =iMA( NULL, 0, ma3, 0, MODE_EMA, 0, i);
if (t1>30.0 && t11<30.0 && t1>t11 && t2>t3)
{
CrossUp[i] = Low[i] - Range*0.2;
}
if (t1<70.0 && t11>70.0 && t1<t11 && t2<t3)
{
CrossDown[i] = High[i] + Range*0.2;
}
}
return(0);
} |
|