设为首页 收藏本站 切换语言

这个指标我想改成邮件报警,我改后报了3个错,有劳大神帮我看看,我刚学写指标

| 发表于 2023-2-22 18:16:26 | 显示全部楼层 |复制链接
//+------------------------------------------------------------------+
//|                                                     Gimmebar.mq4 |
//| See Joe Ross Trading Manual on Gimme-Bars (e.g. from the         |
//| library on www.trading-naked.com)  
//|Bolllitouch - yet another perky mod                                |
//+------------------------------------------------------------------+
#property  copyright "by Shimodax, 2005"
#property  link      "http://www.strategybuilder.com"


//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 6
#property  indicator_color1  SlateBlue
#property  indicator_color2  SlateBlue
#property  indicator_color3  Pink
#property  indicator_color4  LightBlue
#property  indicator_color5  Pink
#property  indicator_color6  LightBlue


//---- indicator parameters
extern int BobaPeriod= 20;
extern double BobaDeviations= 2;


//---- indicator buffers
double     BufferBand1[];
double     BufferBand2[];
double     BufferSell[];
double     BufferBuy[];
double     BufferSellEntry[];
double     BufferBuyEntry[];




//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
{
   //---- 2 additional buffers are used for counting.

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);

   // two bollies
   SetIndexBuffer(0,BufferBand1);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexDrawBegin(0,BobaPeriod);

   SetIndexBuffer(1,BufferBand2);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,BobaPeriod);

   // marks for gimmees
   SetIndexBuffer(2,BufferSell);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexDrawBegin(2,BobaPeriod);
   SetIndexArrow(2, 167);
   SetIndexEmptyValue(2, 0);

   SetIndexBuffer(3,BufferBuy);  
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexDrawBegin(3,BobaPeriod);
   SetIndexArrow(3, 167);
   SetIndexEmptyValue(3, 0);

   // marks for entries
   SetIndexBuffer(4,BufferSellEntry);
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexDrawBegin(4,BobaPeriod);
   SetIndexArrow(4, 238);
   SetIndexEmptyValue(4, 0);

   SetIndexBuffer(5,BufferBuyEntry);  
   SetIndexStyle(5,DRAW_ARROW);
   SetIndexDrawBegin(5,BobaPeriod);
   SetIndexArrow(5, 236);
   SetIndexEmptyValue(5, 0);



   //---- name for DataWindow and indicator subwindow label
   // IndicatorShortName("GimmeBar ");

   //---- initialization done
   return(0);
}



//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int counted_bars= IndicatorCounted(),
         lastbar;

   if (counted_bars>0)
      counted_bars--;

   lastbar= Bars - counted_bars;

   GimmeeBar(0, lastbar, BufferSell, BufferBuy, BufferSellEntry, BufferBuyEntry, BufferBand1, BufferBand2, BobaPeriod, BobaDeviations);

   return (0);
}   




//+------------------------------------------------------------------+
//| Mark Gimmee-Bars and mark possible entries for deals              |
//+------------------------------------------------------------------+
double GimmeeBar(int offset, int lastbar, double &sellbuf[], double &buybuf[], double &sellbuf2[], double &buybuf2[],
                  double &band1buf[], double&band2buf[], int period, int deviation)
{
   double band1, band2;
   int markerdist= 5;   // distance between bars and marker dots

   lastbar= MathMin(Bars-period, lastbar);   

   //---- main loop
   for(int i= lastbar; i>=offset; i--){

      sellbuf= 0;
      buybuf=0;
      sellbuf2= 0;
      buybuf2=0;

      band1= iCustom(Symbol(),0,"Bands",BobaPeriod,0,BobaDeviations,1,i);
      band2= iCustom(Symbol(),0,"Bands",BobaPeriod,0,BobaDeviations,2,i);

      band1buf= band1;
      band2buf= band2;


      // 1. Prices were rising.
      // 2. Prices touched the upper band.
      // 3. The price bar closed lower than it
      // opened when prices were previously rising.
      // or vice versa

      if (High>=band1)  {
         sellbuf= High + markerdist*Point;
         if (i < 2 )
       
        {
          
                SendMail("boll touch at top","boll signal")
        }
      }



      if (Low<=band2)  {
         buybuf= Low - markerdist*Point;
         if (i < 2 )
       
        {
          
                SendMail("boll touch at bottom","boll signal")
        }

      }


      // Should such a price bar occur, a sell short order is to be executed
      // one tick below the low of the Gimmee bar.

     // if (sellbuf[i+1]!=0 && Low<Low[i+1]-1*Point) {
      //   sellbuf2= Low[i+1]-1*Point;
     // }

     // if (buybuf[i+1]!=0 && High>High[i+1]+1*Point) {
     //    buybuf2= High[i+1]+1*Point;
     // }

   }

   /*
   if (DebugLogger)
      Print(TimeOffset(offset), "BG-GimmeBar ", "");
   */

   return (0);
}

image.png
举报

评论 使用道具

精彩评论2

dfsoft
DDD
| 发表于 2023-3-3 09:34:20 | 显示全部楼层
int counted_bars= IndicatorCounted(),
         lastbar;

这个表达式错误
举报

点赞 评论 使用道具

dfsoft
DDD
| 发表于 2023-3-3 09:35:30 | 显示全部楼层
  band1= iCustom(Symbol(),0,"Bands",BobaPeriod,0,BobaDeviations,1,i);
      band2= iCustom(Symbol(),0,"Bands",BobaPeriod,0,BobaDeviations,2,i);
调用了自定义指标
举报

点赞 评论 使用道具

发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册

简体中文
繁體中文
English(英语)
日本語(日语)
Deutsch(德语)
Русский язык(俄语)
بالعربية(阿拉伯语)
Türkçe(土耳其语)
Português(葡萄牙语)
ภาษาไทย(泰国语)
한어(朝鲜语/韩语)
Français(法语)