<
[原创]MT4阻力支撑源码公布
>本指标为CDP公式在MT4上的实现,使用MT4的Expert调用方式,代码如下:</P>
<>==================================================</P>
<>//+------------------------------------------------------------------+
//| CDP.mq4 |
//| Copyright ?2005,520FXCorp. |
//| http://www.520FX.com |
//+------------------------------------------------------------------+
#property copyright "Copyright, 520FX Corp."
#property link "http://www.520fx.com"</P>
<>//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double cdp,H,L,C,Hn,Ln;
double PT,AH,NH,AL,NL;
//----
H=iMA(NULL,0,1,0,MODE_SMA,PRICE_HIGH,1);
L=iMA(NULL,0,1,0,MODE_SMA,PRICE_LOW,1);
C=iMA(NULL,0,1,0,MODE_SMA,PRICE_CLOSE,1);
Hn=iMA(NULL,0,1,0,MODE_SMA,PRICE_HIGH,2);
Ln=iMA(NULL,0,1,0,MODE_SMA,PRICE_LOW,2);
cdp=(H+L+2*C)/4;
PT=Hn-Ln;
AH=cdp+PT;
NH=cdp*2-L;
AL=cdp-PT;
NL=cdp*2-H;
Comment("[www.520fx.com]强支撑:",AL,"弱支撑:",NL,"弱阻力",NH,"强阻力",AH);
ObjectDelete("水平线");
ObjectDelete("水平线1");
ObjectDelete("水平线2");
ObjectDelete("水平线3");
ObjectCreate("水平线",OBJ_HLINE,0,D\'2005.11.01 10:30\',AL);
ObjectCreate("水平线1",OBJ_HLINE,0,D\'2005.11.01 10:30\',NL);
ObjectCreate("水平线2",OBJ_HLINE,0,D\'2005.11.01 10:30\',NH);
ObjectCreate("水平线3",OBJ_HLINE,0,D\'2005.11.01 10:30\',AH);
return(0);
}
//+------------------------------------------------------------------+</P> |