[C++] 纯文本查看 复制代码//+--------------------------------------------------------------------------+
//| 3 MA Cross w_Alert v2.mq4 |
//| Copyright ?2005, Jason Robinson (jnrtrading) |
//| http://www.jnrtading.co.uk |
//| 3 ma conversion and Alert , David Honeywell , transport.david@gmail.com |
//| http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/ |
//+--------------------------------------------------------------------------+
#property copyright "Copyright ?2005, Jason Robinson (jnrtrading)"
#property link "http://www.jnrtrading.co.uk"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
//----
double CrossUp[];
double CrossDown[];
double prevtime;
double Range, AvgRange;
double fasterMAnow, fasterMAprevious, fasterMAafter;
double mediumMAnow, mediumMAprevious, mediumMAafter;
double slowerMAnow, slowerMAprevious, slowerMAafter;
//----
extern int FasterMA = 5;
extern int FasterShift = -5;
extern int FasterMode = 1;
extern int MediumMA = 20;
extern int MediumShift = -5;
extern int MediumMode = 1;
extern int SlowerMA = 34;
extern int SlowerShift = 0;
extern int SlowerMode = 1;
extern int SoundAlert = 1;
//+------------------------------------------------------------------+
//| 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);
}
int deinit()
{
//----
//----
return(0);
}
int start()
{
int limit, i, counter;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars0) counted_bars--;
//----
limit=Bars-counted_bars;
//----
for(i = 0; i slowerMAnow &&
fasterMAprevious slowerMAafter &&
mediumMAnow > slowerMAnow )
||
(fasterMAnow > slowerMAnow &&
mediumMAnow > slowerMAnow &&
mediumMAprevious slowerMAafter ))
{
CrossUp = Low - Range*0.5;
}
if ((fasterMAnow = slowerMAprevious &&
fasterMAafter = slowerMAprevious &&
mediumMAafter 2000) && (CrossDown[0] > 2000)) { prevtime = 0; }
if ((CrossUp[0] == Low[0] - Range*0.5) && (prevtime != Time[0]) && (SoundAlert != 0))
{
prevtime = Time[0];
Alert(Symbol()," 3 MA Cross Up @ Hour ",Hour()," Minute ",Minute());
}
if ((CrossDown[0] == High[0] + Range*0.5) && (prevtime != Time[0]) && (SoundAlert != 0))
{
prevtime = Time[0];
Alert(Symbol()," 3 MA Cross Down @ Hour ",Hour()," Minute ",Minute());
}
return(0);
}
//-------------------------------------------------------+ |