📅 财经日历 📊 实时波动 📈 大盘云图 📶 行情走势 🆚 投机情绪 🚀 今日热点

    再请教牛老大一个问题

    nihao LV3
    2011-12-12 · 8312 阅读
    和上次的问题有些类似,就是我增加了一个划线指标,可是图中不显示,检查程序没有问题,可是无论如何运行都不行,就是关机后再重新也不行,其他电脑上也是。我只好把最后的赋值修改成具体的数据(倒数第五行的语句 if(MainBuffer[i]>MainBuffer[i+1]) K_Buffer[i]=MainBuffer[i];),然后再恢复成早先的变量,居然成功。不知道是什么道理,烦请解释。谢谢!下面是代码
      #property indicator_separate_window
      #property indicator_minimum -5
      #property indicator_maximum 105
      #property indicator_buffers 6
      #property indicator_color1 LightSeaGreen
      #property indicator_color2 White
      #property indicator_color3 Yellow
      #property indicator_color4 Red
      //---- input parameters
      extern int KPeriod=9;
      extern int DPeriod=3;
      extern int Slowing=3;
      //---- buffers
      double MainBuffer[];
      double SignalBuffer[];
      double HighesBuffer[];
      double LowesBuffer[];
      double J_Buffer[];
      double K_Buffer[];
      //----
      int draw_begin1=0;
      int draw_begin2=0;
      //+------------------------------------------------------------------+
      //| Custom indicator initialization function                         |
      //+------------------------------------------------------------------+
      int init()
        {
         string short_name;
      //---- 2 additional buffers are used for counting.
         IndicatorBuffers(6);
         SetIndexBuffer(4, HighesBuffer);
         SetIndexBuffer(5, LowesBuffer);
      //---- indicator lines
         SetIndexStyle(0,DRAW_LINE);
         SetIndexBuffer(0, MainBuffer);
         SetIndexStyle(1,DRAW_LINE);
         SetIndexBuffer(1, SignalBuffer);
         SetIndexStyle(2,DRAW_LINE);
         SetIndexBuffer(2, J_Buffer);
         SetIndexStyle(3,DRAW_LINE,0,2);
         SetIndexBuffer(3, K_Buffer);
      //---- name for DataWindow and indicator subwindow label
         short_name=\"kdj(\"+KPeriod+\",\"+DPeriod+\",\"+Slowing+\")\";
         IndicatorShortName(short_name);
         SetIndexLabel(0,\"k\");
         SetIndexLabel(1,\"d\");
         SetIndexLabel(2,\"J\");
      //----以下四句都可无?
         draw_begin1=KPeriod+Slowing;//可无
         draw_begin2=draw_begin1+DPeriod;//可无
         SetIndexDrawBegin(0,draw_begin1);//可无
         SetIndexDrawBegin(1,draw_begin2);//可无
      //----
         return(0);
        }
      //+------------------------------------------------------------------+
      //| Stochastic oscillator                                            |
      //+------------------------------------------------------------------+
      int start()
        {
         int    i,k;
         int    counted_bars=IndicatorCounted();
         double price;
      //----
         if(Barsprice) min=price;
               k--;
              }
            LowesBuffer[i]=min;
            i--;
           }
      //---- maximums counting---原程序风格
         i=Bars-KPeriod;
         if(counted_bars>KPeriod) i=Bars-counted_bars-1;
         while(i>=0)
           {
            double max=-1000000;
            k=i+KPeriod-1;
            while(k>=i)
              {
               price=High[k];
               if(maxdraw_begin1) i=Bars-counted_bars-1;
         while(i>=0)
           {
            double sumlow=0.0;
            double sumhigh=0.0;
            for(k=(i+Slowing-1);k>=i;k--)   // 只计算i前的Slowing次循环
              {
               sumlow+=Close[k]-LowesBuffer[k];
               sumhigh+=HighesBuffer[k]-LowesBuffer[k];
              }
            if(sumhigh==0.0) MainBuffer[i]=100.0;
            else MainBuffer[i]=sumlow/sumhigh*100;   //简单平均
            i--;
           }
      //---- last counted bar will be recounted
         if(counted_bars>0) counted_bars--;
         int limit=Bars-counted_bars;
      //---- signal line(D) is simple movimg average
         for(i=0; iMainBuffer[i+1]) K_Buffer[i]=MainBuffer[i];
            }
         return(0);   
        }
      //+------------------------------------------------------------------+
    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 26 个

    nihaoya78 LV5

    发表于 2012-11-22 01:36:01 | 显示全部楼层

    太棒了!  

    纸老虎 LV6

    发表于 2012-11-22 01:36:01 | 显示全部楼层

    我来看看!谢谢  

    外汇配资 LV5

    发表于 2012-11-22 01:36:01 | 显示全部楼层

    帮顶  

    知足常乐 LV6

    发表于 2012-11-22 01:36:01 | 显示全部楼层

    厉害!强~~~~没的说了!  

    叫花子 LV5

    发表于 2012-11-22 01:36:01 | 显示全部楼层

    找个老师学习EA  

    后山俗人 LV5

    发表于 2012-11-22 01:36:01 | 显示全部楼层

    呵呵 那就好好玩吧~~~~  

    qinkui007 LV5

    发表于 2012-11-22 01:36:01 | 显示全部楼层

    哎 怎么说那~~  

    gvfqxvia LV3

    发表于 2015-1-7 02:03:26 | 显示全部楼层

    亏损中……………………

    汇晟黄金外汇Fxs LV7

    发表于 2015-1-31 07:26:34 | 显示全部楼层

    看看是什么东西啊
    123下一页
    您需要登录后才可以回帖 登录 | 注册

    提醒: 禁止引战、谩骂、灌水内容

    微信二维码

    有问题联系客服