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

    这个是MT4自带的MACd后半部分的源码,烦请老师标注一下上面意思!

    2012-12-08 · 5116 阅读
    // it is important to enter the market correctly,
       // but it is more important to exit it correctly...   
       for(cnt=0;cnt<total;cnt++)
         {
          OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
          if(OrderType()<=OP_SELL &&   // check for opened position
             OrderSymbol()==Symbol())  // check for symbol
            {
             if(OrderType()==OP_BUY)   // long position is opened
               {
                // should it be closed?
                if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
                   MacdCurrent>(MACDCloseLevel*Point))
                    {
                     OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                     return(0); // exit
                    }
                // check for trailing stop
                if(TrailingStop>0)  
                  {                 
                   if(Bid-OrderOpenPrice()>Point*TrailingStop)
                     {
                      if(OrderStopLoss()<Bid-Point*TrailingStop)
                        {
                         OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                         return(0);
                        }
                     }
                  }
               }
             else // go to short position
               {
                // should it be closed?
                if(MacdCurrent<0 && MacdCurrent>SignalCurrent &&
                   MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*Point))
                  {
                   OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
                   return(0); // exit
                  }
                // check for trailing stop
                if(TrailingStop>0)  
                  {                 
                   if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                     {
                      if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                        {
                         OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                         return(0);
                        }
                     }
                  }
               }
            }
         }
       return(0);
      }
    // the end.
    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 17 个

    mjb6320251 LV3

    发表于 2012-12-8 14:24:32 | 显示全部楼层

    if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
             MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious)
    上面的“  MathAbs(MacdCurrent)>(MACDOpenLevel*Point) ”看不懂上面意思,请老师指教一下,在前面没有“MathAbs”呀,这里突然冒出来。郁闷!

    小沈阳 LV4

    发表于 2012-12-8 14:24:49 | 显示全部楼层

    0线下方:MacdCurrent<0
    macd指标金叉:MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious
    Diff线向上运行:MaCurrent>MaPrevious

    extern double MACDOpenLevel=3;
    MathAbs(MacdCurrent)>(MACDOpenLevel*Point)
    由于Diff在0线下方,所以MacdCurrent为负数。因此需要MathAbs()取其绝对值。MACDOpenLevel初始值为3;Point随币种、mt4行情服务器的不同,值各不相同。一般在0.01到0.00001之间。

    idc LV4

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    本人出售EA  

    kevinyang88 LV5

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    好人一个  

    □o□ LV6

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    是楼主原创吗  

    wadeking LV3

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    既然来了,就留个脚印  

    就是NB LV4

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    希望可以用些时间了~````  

    EA-fans LV4

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    站个位在说  

    稳赚 LV4

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    最好的,我们一般很难遇到,否则全球通用了,那谁亏呢  
    12下一页
    您需要登录后才可以回帖 登录 | 注册

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

    微信二维码

    有问题联系客服