[MT4指标]请正版或会编码的高手编写这个相对位置指标(日本人常用)
发表于:2012-07-24 15:09只看该作者
3楼
我写了一个,看看:
#property copyright "Copyright 2012, Jacky Gu"
#property link "[email protected] QQ:754800643"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
//---- input parameters
extern int EMAPeriod = 89;
//---- buffers
double CCIBuffer;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 3 additional buffers are used for counting.
IndicatorBuffers(1);
//---- indicator lines
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, CCIBuffer);
//----
if(EMAPeriod <= 0)
EMAPeriod = 89;
//----
SetIndexDrawBegin(0, EMAPeriod);
//---- name for DataWindow and indicator subwindow label
short_name="EMA_DIFF(" + EMAPeriod + ")";
IndicatorShortName(short_name);
SetIndexLabel(0, short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Commodity Channel Index |
//+------------------------------------------------------------------+
int start(){
int i, counted_bars = IndicatorCounted();
if(EMAPeriod <= 1) return(0);
if(Bars <= EMAPeriod) return(0);
if(counted_bars < 1){
for(i = 1; i <= EMAPeriod; i++) CCIBuffer[Bars-i] = 0.0;
}
i = Bars - EMAPeriod + 1;
if(counted_bars > EMAPeriod - 1) i = Bars - counted_bars - 1;
while(i >= 0){
double ema = iMA(NULL, 0, EMAPeriod, 0, MODE_EMA, PRICE_CLOSE, i);
double close = iClose(NULL, 0, i);
CCIBuffer = (close - ema) / ema * 100;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
韬客社区www.talkfx.co
发表于:2012-08-15 23:59只看该作者
4楼
有现成的,叫“BIAS”