|
//+------------------------------------------------------------------+
//| RSI_MA_LevelSignal "HI_Line_Indicators" |
//|
//| SMA-Crossover_Signal.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2009, "
#property link "http://www.metaquotes.net"
#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 = Low - Range*0.2;
}
if (t1<70.0 && t11>70.0 && t1<t11 && t2<t3)
{
CrossDown = High + Range*0.2;
}
}
return(0);
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|