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

    向柒侠请教CLOSEBUY。

    2011-12-04 · 9336 阅读
    这些日子拜读了您老的贴子后,不懂一点编程的我若有所悟,自己用您的模版试着表达了一下我的意思,意思很简单,只用三条均线,
      MA1=5,MA2=10,MA3=30
      当MA1上穿MA2,且MA2在MA3之上时做多。
      当MA2下穿MA2,且MA2在MA3之下时做空。
      
      当MA1上穿MA2时先平掉多仓,
      当MA2下穿MA2先平掉空仓。
      
      可是发现怎么也调用不了CloseBuy和CloseSell,
      整个代码如下,望老师指点。。
      
      
      //+------------------------------------------------------------------+
      //|                                                         kkkk.mq4 |
      //|                                                         mengtong |
      //|                                    http://www.hahahahahahaha.net |
      //+------------------------------------------------------------------+
      #property copyright \"mengtong\"
      #property link      \"http://www.hahahahahahaha.net\"
      
      extern double ma1=5,ma2=10,ma3=30;
      double ma1now,ma1now2,ma2now,ma2now2,ma3now,ma3now2,ma1bnow,ma2bnow,ma3bnow;
      ////////////////////////
      extern string _资金管理_ =\"任选一个\";
      extern bool zijiguanli1= true;//false true、、
      extern bool zijiguanli2= false;//false true、、
      extern bool zijiguanli3= false;//false true、、
      ///////////////////////////////////
      extern double cheng=1;
      int cnt;
      int i;
      string text=\"\";
      double TrailingStop=0;
      double aa=0;
      int s=0,b=0;
      double CurrentBasket=0;
      double LotMM=0;
      double lotstart=0;
      double LotsMax=100;
      extern double lotab=0.1;
      double lots=0;
      double TP=0,TPP=0,SL=0,SLL=0;
      int slip=6;
      ///////////////////////////////////////
      double mode=0;
      double LastOrderType;
      double LastPricesell;
      double LastPricebuy;
      double LastPrice;
      double OpenSells;
      double OpenSellStops;
      double OpenBuys;
      double OpenBuyStops;
      //+------------------------------------------------------------------+
      //| expert initialization function |
      //+------------------------------------------------------------------+
      int init()
      {
      //----
      
      //----
      return(0);
      }
      //+------------------------------------------------------------------+
      //| expert deinitialization function |
      //+------------------------------------------------------------------+
      int deinit()
      {
      //----
      
      //----
      return(0);
      }
      
      //+------------------------------------------------------------------+
      //| expert start function |
      //+------------------------------------------------------------------+
      int start()
      {
      //----
      jiancha();//检查判断
      MoneyManagement();//资金管理
      ma();//指标管理
      zhangchang();//战场管理
      TrailingStop();
      CloseBuy();
      CloseSell();
      xianshi();
      //----
      return(0);
      }
      //+------------------------------------------------------------------+
      void jiancha()
      {
      
      b=0;s=0;
      for (int cnt=0; cntma3now
      && ma1now20) { SLL=Ask-SL*Point; }
      OrderSend(Symbol(),OP_BUY,LotMM,Ask,slip,SLL,TPP,\"M\"+Period()+\"\",0,0,Violet);
      
      return(0); }
      //+------------------------------------------------------------------+
      void sellme(){
      if (TP==0) { TPP=0; } if(TP>0) { TPP=Bid-(TP*Point); }
      if (SL==0) { SLL=0; } if(SL>0) { SLL=Bid+(SL*Point); }
      OrderSend(Symbol(),OP_SELL,LotMM,Bid,2,SLL,TPP,\"M\"+Period()+\"\",0,0,GreenYellow);
      return(0); }
      //+------------------------------------------------------------------+
      
      //+------------------------------------------------------------------+
      
      void TrailingStop()
      {
      for(cnt=OrdersTotal();cnt>=0;cnt--)
      {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() )//&& OrderMagicNumber()==MAGICMA)
      {
      if (OrderType()==OP_SELL)
      {
      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);
      }
      }
      }
      }
      
      if (OrderType()==OP_BUY)
      {
      if(TrailingStop>0)
      {
      if(Bid-OrderOpenPrice()>Point*TrailingStop)
      {
      if(OrderStopLoss() 0 )
      {
      for(i=OrdersTotal()-1;i 0 )
      {
      for(i=OrdersTotal()-1;i
    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 24 个

    偏远城市 LV4

    发表于 2012-11-21 22:58:35 | 显示全部楼层

    说的不错  

    小妹er LV5

    发表于 2012-11-21 22:58:35 | 显示全部楼层

    呵呵 高高实在是高~~~~~  

    咬人知己 LV4

    发表于 2012-11-21 22:58:35 | 显示全部楼层

    请发一个试试,谢谢!RongYuanQiong@163.com 。。。  

    不要找他 LV5

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

    晕死也不多加点分  

    和其正 LV5

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

    支持一下吧  

    一招 LV3

    发表于 2013-6-14 10:51:04 | 显示全部楼层

    支持一下吧  

    ishnlnmt LV3

    发表于 2014-12-12 20:12:55 | 显示全部楼层

    谢谢分享!!!!!

    diamonddust77 LV3

    发表于 2015-1-20 14:30:18 | 显示全部楼层

    多谢分享 看看是什么

    老张 LV7

    发表于 2015-2-5 05:33:11 | 显示全部楼层

    想学EA,拜师,谁收了我吧
    123下一页
    您需要登录后才可以回帖 登录 | 注册

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

    微信二维码

    有问题联系客服