查看: 1688|回复: 10
|
Meta Language 4 的高手请帮帮忙~~
[复制链接]
|
|
//+--------------------------------------------------------------------------+
//| 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/ |
//+--------------------------------------------------------------------------+
/*
+-------------------------------------------------------------------------------+
| Allows you to enter 3 ma periods and it will then show you and alert you at |
| which point the 2 faster ma's "OPEN" are both above or below the Slowest ma . |
+-------------------------------------------------------------------------------+
*/
#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 Aqua
#property indicator_color2 Coral
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; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma
extern int MediumMA = 20;
extern int MediumShift = -5;
extern int MediumMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma
extern int SlowerMA = 34;
extern int SlowerShift = 0;
extern int SlowerMode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma
extern int SoundAlert = 1; // 0 = disabled
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, i, counter;
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 = 0; 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;
fasterMAnow = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i+1);
fasterMAprevious = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i+2);
fasterMAafter = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i-1);
mediumMAnow = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i+1);
mediumMAprevious = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i+2);
mediumMAafter = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i-1);
slowerMAnow = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i+1);
slowerMAprevious = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i+2);
slowerMAafter = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i-1);
if ((fasterMAnow > slowerMAnow &&
fasterMAprevious <= slowerMAprevious &&
fasterMAafter > slowerMAafter &&
mediumMAnow > slowerMAnow )
||
(fasterMAnow > slowerMAnow &&
mediumMAnow > slowerMAnow &&
mediumMAprevious <= slowerMAprevious &&
mediumMAafter > slowerMAafter ))
{
CrossUp = Low - Range*0.5;
}
if ((fasterMAnow < slowerMAnow &&
fasterMAprevious >= slowerMAprevious &&
fasterMAafter < slowerMAafter &&
mediumMAnow < slowerMAnow )
||
(fasterMAnow < slowerMAnow &&
mediumMAnow < slowerMAnow &&
mediumMAprevious >= slowerMAprevious &&
mediumMAafter < slowerMAafter ))
{
CrossDown = High + Range*0.5;
}
}
if ((CrossUp[0] > 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());
}
//Comment(" CrossUp[0] ",CrossUp[0]," , CrossDown[0] ",CrossDown[0]," , prevtime ",prevtime);
//Comment("");
return(0);
}
//+------------------------------------------------------------------+ |
|
|
|
|
|
|
|
发表于 27-5-2010 11:21 AM
|
显示全部楼层
本帖最后由 blue@sky 于 27-5-2010 11:23 AM 编辑
回复 1# Freeman5383
帮什么忙? |
|
|
|
|
|
|
|

楼主 |
发表于 27-5-2010 11:22 AM
|
显示全部楼层
小弟想为这个 indicator 加入 MA 原来的所有功能,可是写来写去就是不通~~~(唉~可能我真的没这方面的学习能力吧~~)
所以才不好意思麻烦大大们帮帮忙~~~
这个 indicator 有三条 MA , 基本功能如 :Period , Mode , Shift 已经有了 ,唯独 Apply to ( Open / Close / High / Low / HL/2 / HLC/3 / HLCC/4 )这个功能没写进去~~
所以小弟想请大大帮忙为每条 MA 都加入这功能 ~~
感激不尽~~~ |
|
|
|
|
|
|
|
发表于 27-5-2010 11:28 AM
|
显示全部楼层
回复 3# Freeman5383
你google下universal ma EA。有人已写出来了。 |
|
|
|
|
|
|
|
发表于 27-5-2010 11:57 AM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 27-5-2010 12:15 PM
|
显示全部楼层
抱歉~~~~
double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)
要加在哪里?????  |
|
|
|
|
|
|
|

楼主 |
发表于 27-5-2010 12:39 PM
|
显示全部楼层
回复 Freeman5383
你google下universal ma EA。有人已写出来了。
blue@sky 发表于 27-5-2010 11:28 
找到了~~
可是这是 EA 对吧???
我要的只是 indicator ~~~
用 Manual Trading ~~~ |
|
|
|
|
|
|
|
发表于 27-5-2010 01:18 PM
|
显示全部楼层
回复 7# Freeman5383
所以以上的code是alert indicator来的?那个code做什么的? |
|
|
|
|
|
|
|

楼主 |
发表于 27-5-2010 01:24 PM
|
显示全部楼层
回复 Freeman5383
所以以上的code是alert indicator来的?那个code做什么的?
blue@sky 发表于 27-5-2010 13:18 
对~~~是一个三条 ma 的 indicator ~~
那些 code 我也看不懂~~~ |
|
|
|
|
|
|
|
发表于 27-5-2010 02:21 PM
|
显示全部楼层
回复 9# Freeman5383
manual一点的方法。
fasterMAnow = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i+1);
fasterMAprevious = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i+2);
fasterMAafter = iMA(NULL, 0, FasterMA, FasterShift, FasterMode, PRICE_CLOSE, i-1);
mediumMAnow = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i+1);
mediumMAprevious = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i+2);
mediumMAafter = iMA(NULL, 0, MediumMA, MediumShift, MediumMode, PRICE_CLOSE, i-1);
slowerMAnow = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i+1);
slowerMAprevious = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i+2);
slowerMAafter = iMA(NULL, 0, SlowerMA, SlowerShift, SlowerMode, PRICE_CLOSE, i-1);
把PRICE_CLOSE 换PRICE_TYPICAL,PRICE_OPEN。 之后compile.
请看这里http://docs.mql4.com/constants/prices
auto一点的方法。
在 extern int SoundAlert = 1; // 0 = disabled 下面加这个line。
extern int MyMAType = 0; // 0=Price_close, 1=Price_open
之后把以上的 PRICE_CLOSE 换成 MyMAType 。
之后compile. |
|
|
|
|
|
|
|
发表于 27-5-2010 02:39 PM
|
显示全部楼层
本帖最后由 blue@sky 于 27-5-2010 03:21 PM 编辑
回复 9# Freeman5383
sorry, double post.
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|