我投资经验算是有7年了吧,逐渐摆脱亏损转为赢利,个人主要做黄金白银,以前一直用国内的软件看盘,因此钱龙版DMI的运用如鱼得水,现在想在MT4中开发出此版本,有人说MT4中ADX DMI都有,但和钱龙版的信号相差太远,钱龙版的更平稳,做趋势的绝对利器。现把我改写一半的有问题的代码贴上,希望相关高手能指点一下!
[C] 纯文本查看 复制代码/*
钱龙版DMI
TR := SMA(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(LOW-REF(CLOSE,1))),N,1);
HD := HIGH-REF(HIGH,1);
LD := REF(LOW,1)-LOW;
DMP:= SMA(IF(HD>0 AND HD>LD,HD,0),N,1);
DMM:= SMA(IF(LD>0 AND LD>HD,LD,0),N,1);
_PDI:= DMP*100/TR;
_MDI:= DMM*100/TR;
PDI: SMA(DMP*100/TR,2,1);
MDI: SMA(DMM*100/TR,2,1);
ADX: SMA(ABS(_MDI-_PDI)/(_MDI+_PDI)*100,N,1);
ADXR:(ADX+REF(ADX,M))/2;
*/
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_level1 0
#property indicator_level2 25
#property indicator_level3 50
extern int N=14;
extern int M=6;
double pdi_buffer[];
double mdi_buffer[];
double adx_buffer[];
double adxr_buffer[];
double TEMP[],TEMP1[],TR[],DMP[],DMM[];
double back(double a,double b)
{
if(a>0 && a>b){
return(a);
}else{
return(0.0);
}
}
int init()
{
string short_name;
IndicatorBuffers(4);
SetIndexBuffer(0,pdi_buffer);
SetIndexBuffer(1,mdi_buffer);
SetIndexBuffer(2,adx_buffer);
SetIndexBuffer(3,adxr_buffer);
SetIndexDrawBegin(0,N+1);
SetIndexDrawBegin(1,N+1);
SetIndexDrawBegin(2,N+1);
SetIndexDrawBegin(3,N+1);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
short_name="my-1("+N+")";
IndicatorShortName(short_name);
return(0);
}
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars0) counted_bars--;
limit=Bars-counted_bars;
for(int i=0; i
|