查看:1472回复:16
第一次开发程序,头都大了!!高手帮助看看对不对
//+------------------------------------------------------------------+
//| MACD&MA.mq4 |
//| Copyright ?2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#include
//---- input parameters
extern int FASE_EMA=5;
extern int SLOW_EMA=34;
extern int MACD_SMA=5;
extern int MA_TIME1=5;
extern int MA_TIME2=10;
extern int MA_TIME3=20;
int time=60;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if ((iMA(NULL,time,MA_TIME1,0,MODE_SMA,PRICE_CLOSE,0)>iMA(NULL,time,MA_TIME2,0,MODE_SMA,PRICE_CLOSE,0)
&& iMA(NULL,time,MA_TIME2,0,MODE_SMA,PRICE_CLOSE,0)>iMA(NULL,time,MA_TIME3,0,MODE_SMA,PRICE_CLOSE,0))
&&((iMACD(NULL,time,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,0)<0)
&&((iMACD(NULL,time,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,1)>0)
||(iMACD(NULL,time,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,2)>0)
||(iMACD(NULL,time,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,3)>0))))
{
PlaySound( "expert.wav");
MessageBox("注意"+Symbol()+"可以做多了",NULL, MB_OK);
}
if ((iMA(NULL,time,MA_TIME1,0,MODE_SMA,PRICE_CLOSE,0)0)
&&((iMACD(NULL,time,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,1)<0)
||(iMACD(NULL,time,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,2)<0)
||(iMACD(NULL,time,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,3)<0))))
{
PlaySound( "expert.wav");
MessageBox("注意"+Symbol()+"可以做空了",NULL, MB_OK);
//----
}
return(0);
}
//+------------------------------------------------------------------+
[ 本帖最后由 老正 于 2005-8-4 09:47 编辑 ]
发表于:2005-08-03 13:22只看该作者
2楼
1,可以用alert函数代替playsound 和messagebox 两个函数,
2,不需要用time=60变量来把这个程序限制在小时图上使用,只要运行时放在小时图上就行了。用0代替time变量可以把它使用在不同的图上。
3,不要使用shift=0的函数,因为当shift=0时函数的值在实际应用上是不确定的值
韬客社区www.talkfx.co
3楼
谢谢maningok高手 ,我第一次编程,实在是不会改了,您帮忙休改一下好吗?
韬客社区www.talkfx.co
发表于:2005-08-04 03:18只看该作者
5楼
//+------------------------------------------------------------------+
//| Copyright ?2005, [email protected]
//| http://man2078.home4u.china.com/|
//+------------------------------------------------------------------+
#property copyright "[email protected]"
#property link "http://man2078.home4u.china.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double buy,sell;
extern int FASE_EMA=5;
extern int SLOW_EMA=34;
extern int MACD_SMA=5;
extern int MA_TIME1=5;
extern int MA_TIME2=10;
extern int MA_TIME3=20;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,233);
SetIndexBuffer(0,buy);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,234);
SetIndexBuffer(1,sell);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
for (int i=Bars-1;i>=0;i--)
{
if
(
(
iMA(NULL,0,MA_TIME1,0,MODE_SMA,PRICE_CLOSE,i)>iMA(NULL,0,MA_TIME2,0,MODE_SMA,PRICE_CLOSE,i)
&& iMA(NULL,0,MA_TIME2,0,MODE_SMA,PRICE_CLOSE,i)>iMA(NULL,0,MA_TIME3,0,MODE_SMA,PRICE_CLOSE,i)
)
&&
(
(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i)<0)
&&
(
(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+1)>0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+2)>0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+3)>0)
)
)
)
{
buy=Low;
if (i==1) Alert("注意"+Symbol()+"可以做多了");
}
if
(
(
iMA(NULL,0,MA_TIME1,0,MODE_SMA,PRICE_CLOSE,i)0)
&&
(
(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+1)<0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+2)<0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+3)<0)
)
)
)
{
sell=High;
if (i==1) Alert("注意"+Symbol()+"可以做空了");
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
[ 本帖最后由 老正 于 2005-8-4 12:55 编辑 ]
韬客社区www.talkfx.co
7楼
maningok 真的不知到怎么感谢您!!!谢谢了!!!我这就试试,这系统可以发出提示的声音吗?
韬客社区www.talkfx.co
发表于:2005-08-04 05:20只看该作者
9楼
有行情的时候会发出声音,并且探出对话框提示你。声音文件可以在tools-options-options菜单里面更改
韬客社区www.talkfx.co
10楼
maningok 我已经上传了图片,您再看看,有些地方没出信号。
韬客社区www.talkfx.co
发表于:2005-08-04 06:04只看该作者
11楼
你画的左面的黄圈里面MACD由正变负,不符合你设定的做空条件,
右边的黄圈里面MACD由负变正,也不符合你的做多条件,所以系统没有信号产生。
不知道这是不是和你最初的想法一致,不如你说说你设计这个系统的最初的想法,我好看看你的条件语句用得对不对。
韬客社区www.talkfx.co
12楼
我的最初想法就是,均线5,10死叉,同时MACD的值由正变负,系统发声音,提示做空;做多相反,可能我的那个原始程序的写的让您误会了
[ 本帖最后由 netbios2008 于 2005-8-4 14:54 编辑 ]
韬客社区www.talkfx.co
发表于:2005-08-04 07:01只看该作者
13楼
//+------------------------------------------------------------------+
//| Copyright ?2005, [email protected]
//| http://man2078.home4u.china.com/|
//+------------------------------------------------------------------+
#property copyright "[email protected]"
#property link "http://man2078.home4u.china.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double buy,sell;
extern int FASE_EMA=5;
extern int SLOW_EMA=34;
extern int MACD_SMA=5;
extern int MA_TIME1=5;
extern int MA_TIME2=10;
extern int MA_TIME3=20;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,233);
SetIndexBuffer(0,buy);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,234);
SetIndexBuffer(1,sell);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
for (int i=Bars-1;i>=0;i--)
{
if
(
(
iMA(NULL,0,MA_TIME1,0,MODE_SMA,PRICE_CLOSE,i)0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+2)>0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+3)>0)
)
)
)
{
buy=Low;
if (i==1) Alert("注意"+Symbol()+"可以做多了");
}
if
(
(
iMA(NULL,0,MA_TIME1,0,MODE_SMA,PRICE_CLOSE,i)>iMA(NULL,0,MA_TIME2,0,MODE_SMA,PRICE_CLOSE,i)
)
&&
(
(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i)>0)
&&
(
(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+1)<0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+2)<0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+3)<0)
)
)
)
{
sell=High;
if (i==1) Alert("注意"+Symbol()+"可以做空了");
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
[ 本帖最后由 maningok 于 2005-8-4 15:05 编辑 ]c.gif
14楼
好我来看,等会贴个图,有机会向您学习
韬客社区www.talkfx.co
发表于:2005-08-04 07:12只看该作者
15楼
//+------------------------------------------------------------------+
//| Copyright ?2005, [email protected]
//| http://man2078.home4u.china.com/|
//+------------------------------------------------------------------+
#property copyright "[email protected]"
#property link "http://man2078.home4u.china.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double buy,sell;
extern int FASE_EMA=5;
extern int SLOW_EMA=34;
extern int MACD_SMA=5;
extern int MA_TIME1=5;
extern int MA_TIME2=10;
extern int MA_TIME3=20;
double LastAlertTime=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,233);
SetIndexBuffer(0,buy);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,234);
SetIndexBuffer(1,sell);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
for (int i=Bars-1;i>=0;i--)
{
if
(
(
iMA(NULL,0,MA_TIME1,0,MODE_SMA,PRICE_CLOSE,i)0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+2)>0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+3)>0)
)
)
)
{
sell=High;
if (i==1 && LastAlertTime!=Time[0])
{
Alert("注意"+Symbol()+"可以做空了");
LastAlertTime=Time[0];
}
}
if
(
(
iMA(NULL,0,MA_TIME1,0,MODE_SMA,PRICE_CLOSE,i)>iMA(NULL,0,MA_TIME2,0,MODE_SMA,PRICE_CLOSE,i)
)
&&
(
(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i)>0)
&&
(
(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+1)<0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+2)<0)
||(iMACD(NULL,0,FASE_EMA,SLOW_EMA,MACD_SMA,PRICE_CLOSE,MODE_MAIN,i+3)<0)
)
)
)
{
buy=Low;
if (i==1 && LastAlertTime!=Time[0])
{
Alert("注意"+Symbol()+"可以做多了");
LastAlertTime=Time[0];
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
韬客社区www.talkfx.co
16楼
哇!太好了,这么快就搞定了,真是高人,相信您那个技术分析的颠峰的软件相当不简单,有机会传我们一招半招的,祝您成功!!!希望能常看到帖子
韬客社区www.talkfx.co
17楼
图就不再另外贴了,和您的一样,非常好
韬客社区www.talkfx.co