CDP指标 新评论 johnsun888 2011.11.23 06:59 从网上搜索的公式,做成带箭头的指标。代码如下: //+------------------------------------------------------------------+ //| CDP.mq4 | //| JOHNSUN YE | //| https://www.mql5.com/go?link=http://www.sedofx.com// | //+------------------------------------------------------------------+ #property copyright "JOHNSUN YE" #property link "https://www.mql5.com/go?link=http://www.sedofx.com//" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Yellow #property indicator_color2 Red double ExtMapBuffer1[]; double ExtMapBuffer2[]; extern int PP22=1; extern int mov=3; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_ARROW,0,2); SetIndexArrow(0,233); SetIndexBuffer(0,ExtMapBuffer1); SetIndexEmptyValue(0,0.0); SetIndexStyle(1,DRAW_ARROW,0,2); SetIndexArrow(1,234); SetIndexBuffer(1,ExtMapBuffer2); SetIndexEmptyValue(1,0.0); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //---- Comment("CDP Indicator with arrows"); if(Digits == 2 || Digits == 4) { PP22 = 1; } else { if(Digits == 3 || Digits == 5) {PP22 = 10;} } int limit; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; limit = Bars - counted_bars; for(int i = 0; i < limit; i++) //---- double H,L,C,Hn,Ln; //---- H=iMA(NULL,0,1,0,MODE_SMA,PRICE_HIGH,i-1); L=iMA(NULL,0,1,0,MODE_SMA,PRICE_LOW,i-1); C=iMA(NULL,0,1,0,MODE_SMA,PRICE_CLOSE,i); Hn=iMA(NULL,0,1,0,MODE_SMA,PRICE_HIGH,i); Ln=iMA(NULL,0,1,0,MODE_SMA,PRICE_LOW,i); double cdp=(H+L+2*C)/4; double PT=Hn-Ln; double AH=cdp+PT; double NH=cdp*2-L; double AL=cdp-PT; double NL=cdp*2-H; ExtMapBuffer1[i]=NL; ExtMapBuffer1[i]=NH; ExtMapBuffer1[i]=Low[i] - mov*PP22 *Point; ExtMapBuffer2[i]=High[i] + mov*PP22 *Point; //---- return(0); } //+------------------------------------------------------------------+ 编码帮助 能不能用mt4编写出这样的曲线EMA(MA(C,N),M)? 请指教,帮我看看源码什么地方错了 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
从网上搜索的公式,做成带箭头的指标。代码如下:
//+------------------------------------------------------------------+
//| CDP.mq4 |
//| JOHNSUN YE |
//| https://www.mql5.com/go?link=http://www.sedofx.com// |
//+------------------------------------------------------------------+
#property copyright "JOHNSUN YE"
#property link "https://www.mql5.com/go?link=http://www.sedofx.com//"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Red
double ExtMapBuffer1[];
double ExtMapBuffer2[];
extern int PP22=1;
extern int mov=3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW,0,2);
SetIndexArrow(0,233);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW,0,2);
SetIndexArrow(1,234);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
Comment("CDP Indicator with arrows");
if(Digits == 2 || Digits == 4) { PP22 = 1; }
else {
if(Digits == 3 || Digits == 5) {PP22 = 10;}
}
int limit;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit = Bars - counted_bars;
for(int i = 0; i < limit; i++)
//----
double H,L,C,Hn,Ln;
//----
H=iMA(NULL,0,1,0,MODE_SMA,PRICE_HIGH,i-1);
L=iMA(NULL,0,1,0,MODE_SMA,PRICE_LOW,i-1);
C=iMA(NULL,0,1,0,MODE_SMA,PRICE_CLOSE,i);
Hn=iMA(NULL,0,1,0,MODE_SMA,PRICE_HIGH,i);
Ln=iMA(NULL,0,1,0,MODE_SMA,PRICE_LOW,i);
double cdp=(H+L+2*C)/4;
double PT=Hn-Ln;
double AH=cdp+PT;
double NH=cdp*2-L;
double AL=cdp-PT;
double NL=cdp*2-H;
ExtMapBuffer1[i]=NL;
ExtMapBuffer1[i]=NH;
ExtMapBuffer1[i]=Low[i] - mov*PP22 *Point;
ExtMapBuffer2[i]=High[i] + mov*PP22 *Point;
//----
return(0);
}
//+------------------------------------------------------------------+