|
|
本帖最后由 JAMS49 于 2012-1-4 12:47 编辑
请帮忙改写唐奇安通道
MaPeriodHL.ex4
(2.66 KB, 下载次数: 56)
原码是20天收盘价的最高价或收盘价的最低价连线成通道,请帮忙改写成:20天最高价或最低价连线成通道,感谢不已。源码如下:
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkSalmon
#property indicator_color2 CornflowerBlue
//---- input p***meters
extern int ExtP***m1=20;
extern int ExtP***m2=20;
extern int PriceMode=0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexDrawBegin(1,ExtP***m1);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(1,ExtP***m2);
SetIndexBuffer(1,ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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;
//----
for(int i=0; i<limit; i++)
//ExtMapBuffer1=iMA(NULL,0,ExtP***m1,MODE_EMA,0,PRICE_CLOSE,i);
{
if(PriceMode == 0) ExtMapBuffer1=Close[iLowest(NULL,0,MODE_CLOSE,ExtP***m1,i)];
if(PriceMode == 1) ExtMapBuffer1=Low[iLowest(NULL,0,MODE_LOW,ExtP***m1,i)];
}
//----
for(i=0; i<limit; i++)
{
if(PriceMode == 0) ExtMapBuffer2=Close[iHighest(NULL,0,MODE_CLOSE,ExtP***m2,i)];
if(PriceMode == 1) ExtMapBuffer2=High[iHighest(NULL,0,MODE_HIGH,ExtP***m2,i)];
}
//---- done
return(0);
}
//+------------------------------------------------------------------+ |
|