2楼
我想编写的指标是这三个指标综合以后的指标.只有在这三个指标都指示作多时,这个指标才指示作多,只有在这三个指标都指示作空时,这个指标才指示作空.
韬客社区www.talkfx.co
3楼
我的操作方法主要有3个指标组成.第一个是均线
(MA(C,21)+MA(C,34))/2,既是21日和34日移动平均线的算术平均.
第二个是KDJ指标的变形,原码如下.
//+------------------------------------------------------------------+
//| BENBEN-KD.mq4 |
//| Copyright ?2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Silver
#property indicator_color2 Yellow
extern int N1=60;
extern int N2=10;
double buffer1;
double buffer2;
double buffer3;
double buffer4;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(4);
SetIndexBuffer(0, buffer3);
SetIndexBuffer(1, buffer4);
SetIndexBuffer(2, buffer1);
SetIndexBuffer(3, buffer2);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
IndicatorShortName("BENBEN-KD("+N1+","+N2+")");
SetIndexLabel(0,"Q");
SetIndexLabel(1,"KK");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i,limit;
//----
limit=Bars-counted_bars;
for(i=0;ihttp://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Silver
#property indicator_color2 Yellow
extern int N1=60;
extern int N2=10;
double buffer1;
double buffer2;
double buffer3;
double buffer4;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(4);
SetIndexBuffer(0, buffer3);
SetIndexBuffer(1, buffer4);
SetIndexBuffer(2, buffer1);
SetIndexBuffer(3, buffer2);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
IndicatorShortName("BENBEN-KD("+N1+","+N2+")");
SetIndexLabel(0,"Q");
SetIndexLabel(1,"KK");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i,limit;
//----
limit=Bars-counted_bars;
for(i=0;i均线,KDJ变形指标中灰线>黄线并且灰线>0,MACD中柱线为红时,发出作多信号,并且给出报警的声音. 反之,当收盘价<均线,KDJ变形指标中灰线<黄线并且灰线<0,MACD中柱线为绿线时,发出作空信号,并且给出报警的声音.
韬客社区www.talkfx.co
4楼
图片中第一个红圈处发出作空信号,因为此时收盘价<均线,MACD柱线为绿色,变形KDJ指标中灰线小于黄线并且灰线<0,
第二个红圈处发出作多信号,因为此时收盘价>均线,MACD柱线为红色,变形KDJ指标中灰线>于黄线并且灰线>0.qiuzhu2.GIF
韬客社区www.talkfx.co
发表于:2005-08-05 04:59只看该作者
5楼
//+------------------------------------------------------------------+
//|
//| Copyright [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 N1=60;
extern int N2=10;
//---- buffers
//+------------------------------------------------------------------+
//| 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()
{
double ma1,ma2,ma,macd,macd1,sto1,sto2,HuiXian,HuangXian;
int LastSignal=0;
for (int i=Bars-1;i>=0;i--)
{
ma1=iMA(NULL,0,21,0,MODE_SMA,PRICE_CLOSE,i);
ma2=iMA(NULL,0,34,0,MODE_SMA,PRICE_CLOSE,i);
ma=(ma1+ma2)/2;
sto1=iStochastic(NULL,0,N1,3,3,MODE_SMA,0,MODE_SIGNAL,i);
sto2=iStochastic(NULL,0,N2,3,3,MODE_SMA,0,MODE_SIGNAL,i);
HuiXian=sto1-50;
HuangXian=sto1-sto2;
macd=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i);
if
(
Close>ma
&& HuiXian>HuangXian && HuiXian>0
&& macd>macd1
&& LastSignal!=1
)
{
buy=Low;
LastSignal=1;
}
if
(
Closec.gif
韬客社区www.talkfx.co
发表于:2005-08-05 05:02只看该作者
6楼
1,两个均线我默认使用的是简单平均,你可以根据自己需要改为指数平均或者其他平均方式
2, MACD的指数我默认设定为12,26,9。你可以根据你的需要更改
韬客社区www.talkfx.co
7楼
厉害,多谢maningok
韬客社区www.talkfx.co
8楼
maningok ,你好,我使用了一下,发现还有一点小问题,如图所示,图中另有两出作多信号,也就是在变形KDJ指标中灰线上穿黄线部分还有作多信号没有指示出来.qiuzhu.GIF
韬客社区www.talkfx.co
发表于:2005-08-05 06:31只看该作者
10楼
我的建议是,你把原来的条件改成MACD的交叉,或者是KDJ的交叉作为买卖信号,而不是依靠他们的值作为交易信号。我已经把MACD交叉作为交易信号的程序写在了下面。还附有图示,你看看这次如何?
[ 本帖最后由 maningok 于 2005-8-5 14:33 编辑 ]d.gif
韬客社区www.talkfx.co
发表于:2005-08-05 06:34只看该作者
11楼
//+------------------------------------------------------------------+
//| Copyright ? [email protected] |
//| http://man2078.home4u.china.com/ |
//+------------------------------------------------------------------+
#property copyright "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 N1=60;
extern int N2=10;
//---- buffers
//+------------------------------------------------------------------+
//| 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()
{
double ma1,ma2,ma,macd,macd1,macd2,sto1,sto2,HuiXian,HuangXian;
for (int i=Bars-1;i>=0;i--)
{
ma1=iMA(NULL,0,21,0,MODE_SMA,PRICE_CLOSE,i);
ma2=iMA(NULL,0,34,0,MODE_SMA,PRICE_CLOSE,i);
ma=(ma1+ma2)/2;
sto1=iStochastic(NULL,0,N1,3,3,MODE_SMA,0,MODE_SIGNAL,i);
sto2=iStochastic(NULL,0,N2,3,3,MODE_SMA,0,MODE_SIGNAL,i);
HuiXian=sto1-50;
HuangXian=sto1-sto2;
macd=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i);
macd1=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+1);
macd2=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i+2);
if
(
Close>ma
&& HuiXian>HuangXian && HuiXian>0
&& macd>macd1 && macd1macd2
)
{
sell=High;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
[ 本帖最后由 maningok 于 2005-8-5 14:37 编辑 ]
韬客社区www.talkfx.co
12楼
好,讲的太透彻了,多谢.
韬客社区www.talkfx.co
发表于:2005-08-06 01:49只看该作者
13楼
学到了很多东西,谢谢。
韬客社区www.talkfx.co