3楼
这个我知道。但我需要反复切换的。
而如果用模板,每次应用模板会删掉图上原有的画线。。。。而画线是我的重要工具。
所以只能编个指标,并用快捷键切换了
韬客社区www.talkfx.co
4楼
晕啊。我自己写了一个,怎么画出来和手工添加4条均线完全不同呢?
高手帮我看看
//+------------------------------------------------------------------+
//| Copyright ?2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Black
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Lime
//---- input parameters
extern int MA1Period=30;
extern int MA1Shift=0;
extern int MA2Period=20;
extern int MA2Shift=0;
extern int MA3Period=10;
extern int MA3Shift=0;
extern int MA4Period=5;
extern int MA4Shift=0;
//---- indicator buffers
double ExtMA1Buffer;
double ExtMA2Buffer;
double ExtMA3Buffer;
double ExtMA4Buffer;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- line shifts when drawing
SetIndexShift(0,MA1Shift);
SetIndexShift(1,MA2Shift);
SetIndexShift(2,MA3Shift);
SetIndexShift(3,MA4Shift);
//---- first positions skipped when drawing
SetIndexDrawBegin(0,MA1Shift+MA1Period);
SetIndexDrawBegin(1,MA2Shift+MA2Period);
SetIndexDrawBegin(2,MA3Shift+MA3Period);
SetIndexDrawBegin(3,MA4Shift+MA4Period);
//---- 4 indicator buffers mapping
SetIndexBuffer(0,ExtMA1Buffer);
SetIndexBuffer(1,ExtMA2Buffer);
SetIndexBuffer(2,ExtMA3Buffer);
SetIndexBuffer(3,ExtMA4Buffer);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
//---- index labels
SetIndexLabel(0,"MA1");
SetIndexLabel(1,"MA2");
SetIndexLabel(2,"MA3");
SetIndexLabel(3,"MA4");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| 4MA |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
for(int i=0; i
韬客社区www.talkfx.co
5楼
哈哈,以及解决了。是平滑模式的区别。
自己动手丰衣足食啊。不过还是把最终代码贴上来,需要就用!
//+------------------------------------------------------------------+
//| Neo's 4MA.mq4 |
//| Copyright ?2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Black
#property indicator_color2 Red
#property indicator_color3 DeepSkyBlue
#property indicator_color4 DarkSeaGreen
//---- input parameters
extern int MA1Period=30;
extern int MA1Shift=0;
extern int MA2Period=20;
extern int MA2Shift=0;
extern int MA3Period=10;
extern int MA3Shift=0;
extern int MA4Period=5;
extern int MA4Shift=0;
//---- indicator buffers
double ExtMA1Buffer;
double ExtMA2Buffer;
double ExtMA3Buffer;
double ExtMA4Buffer;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- line shifts when drawing
SetIndexShift(0,MA1Shift);
SetIndexShift(1,MA2Shift);
SetIndexShift(2,MA3Shift);
SetIndexShift(3,MA4Shift);
//---- first positions skipped when drawing
SetIndexDrawBegin(0,MA1Shift+MA1Period);
SetIndexDrawBegin(1,MA2Shift+MA2Period);
SetIndexDrawBegin(2,MA3Shift+MA3Period);
SetIndexDrawBegin(3,MA4Shift+MA4Period);
//---- 4 indicator buffers mapping
SetIndexBuffer(0,ExtMA1Buffer);
SetIndexBuffer(1,ExtMA2Buffer);
SetIndexBuffer(2,ExtMA3Buffer);
SetIndexBuffer(3,ExtMA4Buffer);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
//---- index labels
SetIndexLabel(0,"MA1");
SetIndexLabel(1,"MA2");
SetIndexLabel(2,"MA3");
SetIndexLabel(3,"MA4");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Neo's 4MA |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
for(int i=0; i
韬客社区www.talkfx.co
发表于:2006-10-29 07:05只看该作者
7楼
谢谢
韬客社区www.talkfx.co