您需要 登录 才可以下载或查看,没有帐号?注册
新手:看了一遍变色均线的教程后,自编了一个交叉变色均线指标,金叉,死叉变色是可以了,但是变色的位置出现问题了,变色发生不在交叉点上,用SMA的情况会好一点,但用LWMA就变色的情况就会更糟!
希望牛版,老师们指点指点,帮助解决这问题,跟大家分享自己第一个写的指标!谢谢
//+------------------------------------------------------------------+
//| 变色均线.mq4 |
//| OZB |
//| |
//+------------------------------------------------------------------+
#property copyright OZB
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Blue
extern int 快线=10;
extern int 慢线=30;
double 快线dou[];
double 快线kong[];
double 慢线dou[];
double 慢线kong[];
int init()
{
SetIndexBuffer(0,快线dou);
SetIndexBuffer(1,快线kong);
SetIndexBuffer(2,慢线dou);
SetIndexBuffer(3,慢线kong);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexDrawBegin(0,快线);
SetIndexDrawBegin(1,快线);
SetIndexDrawBegin(2,慢线);
SetIndexDrawBegin(3,慢线);
IndicatorDigits(Digits);
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
int start()
{
double temp0,temp1,temp2,temp3;
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars0) counted_bars--;
limit=Bars-counted_bars;
for(int i=limit; i i--)
{
快线dou i =EMPTY_VALUE;
快线kong i =EMPTY_VALUE;
慢线dou i =EMPTY_VALUE;
慢线kong i =EMPTY_VALUE;
temp0=iMA(NULL,0,快线,0,MODE_LWMA,PRICE_CLOSE,i);
temp1=iMA(NULL,0,快线,0,MODE_LWMA,PRICE_CLOSE,i+1);
temp2=iMA(NULL,0,慢线,0,MODE_LWMA,PRICE_CLOSE,i);
temp3=iMA(NULL,0,慢线,0,MODE_LWMA,PRICE_CLOSE,i+1);
if(iMA(NULL,0,快线,0,MODE_SMA,PRICE_CLOSE,i) =iMA(NULL,0,慢线,0,MODE_SMA,PRICE_CLOSE,i))
{快线dou i =temp0; 快线dou[i+1]=temp1;慢线dou i =temp2; 慢线dou[i+1]=temp3;}
else {快线kong i =temp0; 快线kong[i+1]=temp1;慢线kong i =temp2; 慢线kong[i+1]=temp3;}
}
return(0);
}
//+------------------------------------------------------------------+
[/td][/tr]
外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!