下载MetaTrader 5
要添加评论,请登录注册
最新的MQL5.community 新闻是什么?看板部分会告诉您!
liuxiaodong
282
liuxiaodong 2007.09.18 08:29 
   代码在下一贴
liuxiaodong
282
liuxiaodong 2007.09.18 08:38  
//+------------------------------------------------------------------+
//|                                                  Liu's--20--.mq4 |
//|                       Copyright ?2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
 
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexDrawBegin(0,1);
   IndicatorShortName("Lius-test-");
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   double a0,b0,c0,d0,a1,b1,c1,d1;
   for(int i=0; i<limit; i++)
   {
  a0=iOpen(NULL,0,i);
  b0=iClose(NULL,0,i);
  c0=iHigh(NULL,0,i);
  d0=iLow(NULL,0,i);
  a1=iOpen(NULL,0,i-1);
  b1=iClose(NULL,0,i-1);
  c1=iHigh(NULL,0,i-1);
  d1=iLow(NULL,0,i-1);
  if(b0>a0)
  //阳烛
{
if(a0-b1>0)
{
ExtMapBuffer1[i]=MathRound(((a0-b1)+(c0-d0))/Point);
}
if (a0-b1<=0)
{
ExtMapBuffer1[i]=MathRound((c0-d0)/Point);
}
}
//阴烛
if(b0<a0)
{
if(a0-b1>0)
{
ExtMapBuffer1[i]=MathRound(((c0-a0)+(b0-d0)+(a0-b1))/Point);
}
if (a0-b1<=0)
{
ExtMapBuffer1[i]=MathRound(((c0-a0)+(b0-d0))/Point);
}
}
//十字
else 
{
if(a0-b1>0)
{
ExtMapBuffer1[i]=MathRound(((c0-d0)+(a0-b1))/Point);
}
if(a0-b1<=0)
{
ExtMapBuffer1[i]=MathRound((c0-d0)/Point);
}
}
} 
//
//----
   
//----
   return(0);
  }
//+-------------------------------------------http://hi.baidu.com/shangwujuhttp://hi.baidu.com/shangwujuhttp://hi.baidu.com/shangwuju-----------------------+
Rashid Umarov
管理员
6600
Rashid Umarov 2007.09.18 10:08  
Your code has an error. See
 a1=iOpen(NULL,0,i-1);
  b1=iClose(NULL,0,i-1);
  c1=iHigh(NULL,0,i-1);
  d1=iLow(NULL,0,i-1);
Which value these variables will be when I==0 ? Negative index of bar is not allowed.
liuxiaodong
282
liuxiaodong 2007.09.18 13:21  
hello Rosh can you give me a ringt case? thanks!
liuxiaodong
282
liuxiaodong 2007.09.20 04:09  

Rosh 你好“请问我前面代码中i和bars用法对吗?谢谢!

Rashid Umarov
管理员
6600
Rashid Umarov 2007.09.20 09:23  
I think you mean similar that
//+------------------------------------------------------------------+
//|                                                  Liu's--20--.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                    '刚写的一个多空力量消长的指标 ;(只写了多方的)不知对不对请看!' |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "'刚写的一个多空力量消长的指标 ;(只写了多方的)不知对不对请看!'"
 
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexDrawBegin(0,1);
   IndicatorShortName("Lius-test-");
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   double a0,b0,c0,d0,a1,b1,c1,d1;
   for(int i=limit; i>=0; i--)
      {
      a0=Open[i];
      b0=Close[i];
      c0=High[i];
      d0=Low[i];
      a1=Open[i+1];
      b1=Close[i+1];
      c1=High[i+1];
      d1=Low[i+1];
      if(b0>a0)
         //??
         {
         if(a0-b1>0)
            {
            ExtMapBuffer1[i]=MathRound(((a0-b1)+(c0-d0))/Point);
            }
         if (a0-b1<=0)
            {
            ExtMapBuffer1[i]=MathRound((c0-d0)/Point);
            }
         }
      //??
      if(b0<a0)
         {
         if(a0-b1>0)
            {
            ExtMapBuffer1[i]=MathRound(((c0-a0)+(b0-d0)+(a0-b1))/Point);
            }
         if (a0-b1<=0)
            {
            ExtMapBuffer1[i]=MathRound(((c0-a0)+(b0-d0))/Point);
            }
         }
      //??
      else 
         {
         if(a0-b1>0)
            {
            ExtMapBuffer1[i]=MathRound(((c0-d0)+(a0-b1))/Point);
            }
         if(a0-b1<=0)
            {
            ExtMapBuffer1[i]=MathRound((c0-d0)/Point);
            }
         }
      } 
//
//----
   
//----
   return(0);
  }
//+-------------------------------------------


Picture
liuxiaodong
282
liuxiaodong 2007.09.20 18:36  

Rosh:

I got it!

thank you very much!

have a good day!

/
要添加评论,请登录注册