tomizl 发表于 2006-10-7 01:59

请会混沌指标编写的帮忙看一下

本人正在mt4上编写一个混沌区域k线指标,按 3LineBreak.mq4的程序编写,指标思想很简单,ao ac为红,k线上涂红色,ao ac为绿,k线上涂绿色,ao ac为一红一绿,k线上涂灰色。
下面是自己写的区域程序代码:
#property copyright "Poul Trade Forum"
#property link      "http://forex.kbpauk.ru/"
#property indicator_chart_window
#property indicator_buffers 2

//---- input parameters
//extern int Lines_Break=3;
//---- buffers
double HighBuffer[];
double LowBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Red);

   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);

// SetIndexEmptyValue(0,0);
//SetIndexEmptyValue(1,0);

//---- name for DataWindow and indicator subwindow label
   short_name="COLORLINE";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

//----
   SetIndexDrawBegin(0,0);
   SetIndexDrawBegin(1,0);
//----

   return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                     |
//+------------------------------------------------------------------+

int start()
{
      double Buffer1[];
      double Buffer2[];
      int    counted_bars=IndicatorCounted(),i,limit;

//---- TODO: add your code here
if (counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for (i=limit;i>=0;i--)
{
   Buffer1=iAO(NULL,0,i);
   Buffer2=iAC(NULL,0,i);
   if(Buffer1>Buffer1&&Buffer2>Buffer2)
   {
      HighBuffer=High;
      LowBuffer=Low;
   }
if(Buffer1<Buffer1&&Buffer2<Buffer2)
   {
   HighBuffer=High;
      LowBuffer=Low;
   }
}

   return(0);
}

因水平有限做不下去了。请高手帮一下,原代码如下

//+------------------------------------------------------------------+
//|                                                   3LineBreak.mq4 |
//|                               Copyright ?2004, Poul_Trade_Forum |
//|                                                         Aborigen |
//|                                          http://forex.kbpauk.ru/ |
//+------------------------------------------------------------------+
#property copyright "Poul Trade Forum"
#property link      "http://forex.kbpauk.ru/"
#property indicator_chart_window
#property indicator_buffers 2

//---- input parameters
extern int Lines_Break=3;
//---- buffers
double HighBuffer[];
double LowBuffer[];
double VALUE1,VALUE2,Swing=1,OLDSwing;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2,Blue);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2,Red);

   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);

   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);

//---- name for DataWindow and indicator subwindow label
   short_name="3LineBreak";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
//----

   return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                     |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here

//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int    counted_bars=IndicatorCounted(),i,shift;
   

//---- TODO: add your code here
if (counted_bars==0) counted_bars=Lines_Break+1;
i=(Bars-counted_bars);

for (shift=i; shift>=0;shift--)
{

OLDSwing=Swing;

VALUE1=High;
VALUE2= Low;
if (OLDSwing==1 &&Low<VALUE2) Swing=-1;
if (OLDSwing==-1 && High>VALUE1 ) Swing=1;

if (Swing==1)
{ HighBuffer=High; LowBuffer=Low; }

if (Swing==-1)
{ LowBuffer=High; HighBuffer=Low; }


//----
}
   return(0);
}
//+------------------------------------------------------------------+

菜鸟也炒汇 发表于 2006-10-7 21:18

倒俺是搞外汇的还是个菜鸟你好象放错地方了
页: [1]
查看完整版本: 请会混沌指标编写的帮忙看一下