HA
//+------------------------------------------------------------------+//| HA.mq4 |
//| Copyright ?2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#propertycopyright "Copyright ?2004, MetaQuotes Software Corp."
#propertylink "http://www.metaquotes.net/"
//---- indicator settings
#propertyindicator_chart_window
#propertyindicator_buffers 2
#propertyindicator_color1White
#propertyindicator_color2Red
#propertyindicator_width11
#propertyindicator_width21
//---- indicator buffers
double HighBuffer[];
double LowBuffer[];
double OpenBuffer[];
double CloseBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(4);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexDrawBegin(0,2);
SetIndexDrawBegin(1,2);
IndicatorDigits(Digits+2);
//---- 4 indicator buffers mapping
SetIndexBuffer(0,HighBuffer);
SetIndexBuffer(1,LowBuffer);
SetIndexBuffer(2,OpenBuffer);
SetIndexBuffer(3,CloseBuffer);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("HA");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Heiken Ashi |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- 引用Heiken Ashi指标的开盘价
for(int i=0; i<limit; i++)
OpenBuffer=iCustom(NULL, 0, "Heiken Ashi",2, i);
//---- 引用Heiken Ashi指标的收盘价
for(i=0; i<limit; i++)
CloseBuffer=iCustom(NULL, 0, "Heiken Ashi",3, i);
//---- 给柱线上色
for(int j = i; j >= 0; j--)
{
if(OpenBuffer < CloseBuffer)
{
HighBuffer = High;
LowBuffer = Low;
}
else
if(OpenBuffer > CloseBuffer)
{
LowBuffer = High;
HighBuffer = Low;
}
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
{:1_186:} 顶下 顶下 支持下
页:
[1]