# 什么是MT4?
我就当你了解什么是MT4了
MT4就是META. TRADER 4# 什么是EA?我也当你了解什么是EA了EA 就是 Expert AdviserEA 就是智能交易系统智能教育系统就是:-软件自己分析下订单-软件自己分析提成利润-软件自己分析砍仓止输# 什么是速成班?就是你在很短迅速的时期内就可以学会如何编撰EA是的,快则8个学习小时慢则24个学习小时# 什么叫“易学难精”?就是你迅速的就上手,难在形成厉害的大神。这需要时间逐渐的去研究编撰。久而久之你就可以是EA编撰大神了。第一课::了解EA的形式
* 下方就是EA的编撰形式//#property copyright "外汇联盟 www.FXunion.com QQ群144033"
#property link ""
//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init(){//----//----return(0);}//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit(){//----//----return(0); }//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----//----return(0); }//+------------------------------------------------------------------+#property copyright "外汇联盟 www.FXunion.com QQ群144033"
#property link ""
写与不写都无所谓我们也不用理他* //+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init(){//----//以后或许有用到//----return(0);}//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit(){//----//以后或许有用到//----return(0); }这两个很少用到。高大神才会用速成班的话,这个可以不用理他。放在一边先,以后才学怎样用它。* //+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----//主程式//----return(0); }//+------------------------------------------------------------------+这个就是EA开始操作的重要部分以上的EA的编撰形式我们改成如下:#property copyright "外汇联盟 www.FXunion.com QQ群144033"
#property link ""
//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init(){//----/以后或许有用到//----return(0);}//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit(){//----/以后或许有用到//----return(0); }//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----//主程式//----return(0); }//+------------------------------------------------------------------+ * 什么是“.mq4”?EA制作好了就save成.mq4的文件这文件是值得修改的* 什么是“.ex4”?EA制作好了按“编撰”就会自动save成.ex4的文件这文件是不可以被修改的这文件是加密的可以卖出的文件。
第二课:EA重要部分
* 回到EA重要部分//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----//主程式//----return(0); }//+------------------------------------------------------------------+* 我们要知道EA是由上面向下读的所以我们在编撰方面要有逻辑思考下方是编撰的形式//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----MoneyManagement(); macd(); ma(); zhangchang(); buyme(); sellme(); xianshi(); //----return(0); }//+------------------------------------------------------------------+void MoneyManagement() {}//+------------------------------------------------------------------+void macd() {}//+------------------------------------------------------------------+void ma() {}//+------------------------------------------------------------------+void zhangchang() {}//+------------------------------------------------------------------+void buyme() {}//+------------------------------------------------------------------+void sellme() {}//+------------------------------------------------------------------+void buyme() {}//+------------------------------------------------------------------+void xianshi() {}//+------------------------------------------------------------------+/////end* // 这两划代表右边的不要读也可以说是注解注意:EA不会读中文符号。比如这个“”这个就可以 ""#property copyright "外汇联盟 www.FXunion.com QQ群144033"
#property link ""
//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init(){//----//以后或许有用到//----return(0);}//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit(){//----//以后或许有用到//----return(0); }//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----//主程式MoneyManagement(); //资金管理macd(); //指标管理ma(); //指标管理zhangchang(); //战场管理buyme(); //买上sellme(); //买下xianshi(); //表明管理//----return(0); }//+------------------------------------------------------------------+void MoneyManagement() {//子程式//这边要写一部分东西}//+------------------------------------------------------------------+void macd() {//子程式//这边要写一部分东西}//+------------------------------------------------------------------+void ma() {//子程式//这边要写一部分东西}//+------------------------------------------------------------------+void zhangchang() {///子程式//这边要写一部分东西}//+------------------------------------------------------------------+void buyme() {//子程式//这边要写一部分东西}//+------------------------------------------------------------------+void sellme() {//子程式//这边要写一部分东西}//+------------------------------------------------------------------+void buyme() {//子程式//这边要写一部分东西}//+------------------------------------------------------------------+void xianshi() {//子程式//这边要写一部分东西}//+------------------------------------------------------------------+/////end* 假使你在上面加这个xianshi2(); 下面就加这个//////////////////////////void xianshi2() {//这边要写一部分东西}////////////////////////////可以任意无限的加。
第三课::加入指标
* //////////////////////////////void ma(){ma1now = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma1now2 = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma2now = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma2now2 = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma1bnow = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_OPEN,0); ma2bnow = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_OPEN,0); }////////////////////////ma1now是代表的字你可以写成什么都可以PR洲际交易所_CLOSE是ma最新的参数PR洲际交易所_OPEN是ma开始的参数ma1now = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_CLOSE,0); 这个整句是死的。你只要copy&press就可以用了ma1是ma的参数号码或bar假使如此写法,他人不能更改参数double ma1=1,ma2=2;double ma1now,ma1now2,ma2now,ma2now2,ma1bnow,ma2bnow;如此写法,他人可以更改参数extern double ma1=1,ma2=2;这个是要放在#property上面那边的* 其它指标的写法macd1now=iMACD(NULL,0,macd1,macd1*2,1,PR洲际交易所_CLOSE, MODE_MAIN,0); zigzag1now=iCustom(NULL,0,"ZigZag",2,deviation,bac kstep,0,0); Highest1now=High[iHighest(NULL,0,MODE_HIGH,Highest1,0)];Lowest1now=Low[iLowest(NULL,0,MODE_LOW,Lowest1,0)];iTrend1now=iCustom(NULL,0,"iTrend",2,0,0,iTrend1,0 ,iTrend1,0,0,1); wpr1now = iWPR(Symbol(),0,wpr1,0); 指标写法是不用记住的网上可以寻到很多指标的写法* 有了指标我们可以更改我们的EA了更改如下:注意看看刚刚的指标加在什么地方什么位置#property copyright "外汇联盟 www.FXunion.com QQ群144033"
#property link ""
extern double ma1=1,ma2=2;double ma1now,ma1now2,ma2now,ma2now2,ma1bnow,ma2bnow;//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init(){//----//----return(0);}//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit(){//----//----return(0); }//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----MoneyManagement(); //资金管理macd(); //指标管理ma(); //指标管理zhangchang(); //战场管理buyme(); //买上sellme(); //买下xianshi(); //表明管理//----return(0); }//+------------------------------------------------------------------+void MoneyManagement() {//这边要写一部分东西}//+------------------------------------------------------------------+void macd() {//这边要写一部分东西}//+------------------------------------------------------------------+void ma(){ma1now = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma1now2 = iMA(NULL,0,ma10,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma2now = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma2now2 = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma1bnow = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_OPEN,0); ma2bnow = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_OPEN,0); }//+------------------------------------------------------------------+void zhangchang() {//这边要写一部分东西}//+------------------------------------------------------------------+void buyme() {//这边要写一部分东西}//+------------------------------------------------------------------+void sellme() {//这边要写一部分东西}//+------------------------------------------------------------------+void buyme() {//这边要写一部分东西}//+------------------------------------------------------------------+void xianshi() {//这边要写一部分东西}//+------------------------------------------------------------------+/////end* 注意这个{},不要糊涂的删除了也不晓得会出错的注意这个可以写成如此效果一样double ma1=1;double ma2=2;double ma1now;double ma1now2;double ma2now;double ma2now2;double ma1bnow;double ma2bnow;* extern double ma1=1;extern double ma2=2;如此写可以表明在EA开始的修改处
第四课-资金管理
* 这个将放在#property上面那边////////////////////////extern string _资金管理_ ="任选一个";extern bool zijiguanli1 = true;//false true、、extern bool zijiguanli2= false;//false true、、extern bool zijiguanli3= false;//false true、、///////////////////////////////////true=要false =不要用我给予了三个资金管理作为参考你可以自己增长自己喜欢的资金管理方案* /////////////////////////////////////void MoneyManagement() {lotstart=(AccountBalance()*lotab/10000); lots=lotstart;if(cheng==0){cheng=1;}CurrentBasket=AccountEquity()-AccountBalance(); /////////////////////////////////////////////////////////////////if(zijiguanli1){ LotMM = lots;}/////////////////////////////////////////////////////////////////if(zijiguanli2){if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lots*(OrdersTotal()*cheng)+ lotstart,2); }if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }}/////////////////////////////////////////////////////////////////if(zijiguanli3){if(s+b==0){aa=1;}if(s+b==1){aa=3;}if(s+b==2){aa=7;}if(s+b==3){aa=11;}if(s+b==4){aa=20;}if(s+b==5){aa=31;}if(s+b==6){aa=42;}if(s+b==7){aa=54;}if(s+b==8){aa=66;}if(s+b==9){aa=76;}if(s+b>=10){aa=66;}if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lotstart*aa,2); }if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }}/////////////////////////////////////////////////////////////////if(LotMMif(LotMM>LotsMax){LotMM=LotsMax;}}//end zijiguanli//////////////////////////////////////////注意:这个资金管理加了很多新的词句所以我们要加之去#property上面那边不然会出错* 新的词句:extern double cheng=1;double aa=0;int s=0,b=0;intdouble CurrentBasket=0;double LotMM=0;double lotstart=0;double LotsMax=100;extern double lotab=0.1;double lots=0;* 注意:double 是有小数点的int 是没有小数点的* 注意:if(){}很容易用,比如:if(LotMM 意思就是:假使LotMM小过lots,LotMM就等于0.01。if(LotMM>LotsMax){LotMM=LotsMax;}意思就是:假使LotMM大过LotsMax,LotMM就等于LotsMax。不会的话,不要紧copy&press就可以用了把void MoneyManagement() { }copy&press到我们EA模板去结果如下:// #property copyright "外汇联盟 www.FXunion.com QQ群144033"
#property link ""
extern double ma1=1,ma2=2;double ma1now,ma1now2,ma2now,ma2now2,ma1bnow,ma2bnow;////////////////////////extern string _资金管理_ ="任选一个";extern bool zijiguanli1= true;//false true、、extern bool zijiguanli2= false;//false true、、extern bool zijiguanli3= false;//false true、、///////////////////////////////////extern double cheng=1;double aa=0;int s=0,b=0;int double CurrentBasket=0;double LotMM=0;double lotstart=0;double LotsMax=100;extern double lotab=0.1;double lots=0;//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init(){//----//----return(0);}//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit(){//----//----return(0); }//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----MoneyManagement(); //资金管理macd(); //指标管理ma(); //指标管理zhangchang(); //战场管理buyme(); //买上sellme(); //买下xianshi(); //表明管理//----return(0); }//+------------------------------------------------------------------+void MoneyManagement() {lotstart=(AccountBalance()*lotab/10000); lots=lotstart;if(cheng==0){cheng=1;}CurrentBasket=AccountEquity()-AccountBalance(); /////////////////////////////////////////////////////////////////if(zijiguanli1){ LotMM = lots;}/////////////////////////////////////////////////////////////////if(zijiguanli2){if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lots*(OrdersTotal()*cheng)+ lotstart,2); }if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }}/////////////////////////////////////////////////////////////////if(zijiguanli3){if(s+b==0){aa=1;}if(s+b==1){aa=3;}if(s+b==2){aa=7;}if(s+b==3){aa=11;}if(s+b==4){aa=20;}if(s+b==5){aa=31;}if(s+b==6){aa=42;}if(s+b==7){aa=54;}if(s+b==8){aa=66;}if(s+b==9){aa=76;}if(s+b>=10){aa=66;}if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lotstart*aa,2); }if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }}/////////////////////////////////////////////////////////////////if(LotMMif(LotMM>LotsMax){LotMM=LotsMax;}}//end zijiguanli//+------------------------------------------------------------------+void macd() {//这边要写一部分东西}//+------------------------------------------------------------------+void ma(){ma1now = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma1now2 = iMA(NULL,0,ma10,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma2now = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma2now2 = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma1bnow = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_OPEN,0); ma2bnow = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_OPEN,0); }//+------------------------------------------------------------------+void zhangchang() {//这边要写一部分东西}//+------------------------------------------------------------------+void buyme() {//这边要写一部分东西}//+------------------------------------------------------------------+void sellme() {//这边要写一部分东西}//+------------------------------------------------------------------+void buyme() {//这边要写一部分东西}//+------------------------------------------------------------------+void xianshi() {//这边要写一部分东西}//+------------------------------------------------------------------+/////end* 资金管理有三个方案:资金管理1=平注资金管理2=1,2,3,4,5...可以乘,假使你把cheng改成2或3或0.2资金管理3是固定式,1,3,7,11.。
第五课:策略:战场
* 这里是整个EA最重要的地方这里策略改变无穷高深莫测就是这里作怪* 在这里你要想:。你的EA要怎样下注何时买上?何时买下?怎样买上?怎样买下?有买上又买下?何时退场?条件满足是很重要的* 在这里我给个简单的策略-ma1黄金交叉ma2,EA买上-ma1死亡交叉ma2,EA买下-有赚25点就出场-假使亏的时机亏50点就出场* 是如此编撰的:ma1now>ma2now如此一句是不够条件的ma1now>ma2now&& ma1now2这个就是黄金交叉的编撰法* 倒过来ma1now && ma1now2>ma2now2这个就是死亡交叉的编撰法* 但是条件依旧不够的再加ma1now>ma2now&& ma1now2 && s+b==0s+b==0 意思就是 买上+买下等于没有没有下注,假使遇到条件符合就可下方注的意思&& 的意思就是“再加”什么什么的条件那么整句是如此编撰if(什么什么){就什么什么}就是用这个if(ma1now>ma2now&& ma1now2 && s+b==0){buyme(); }if(ma1now && ma1now2>ma2now2&& s+b==0){sellme(); }* 当下我们就把这两句copy&press到战场去注意:当下又多了两个新的东西buyme()和sellme()你就copy&press buyme()和sellme()的编撰法就可以了。* 结果如下: #property copyright "外汇联盟 www.FXunion.com QQ群144033"
#property link ""
extern double ma1=1,ma2=2;double ma1now,ma1now2,ma2now,ma2now2,ma1bnow,ma2bnow;////////////////////////extern string _资金管理_ ="任选一个";extern bool zijiguanli1= true;//false true、、extern bool zijiguanli2= false;//false true、、extern bool zijiguanli3= false;//false true、、///////////////////////////////////extern double cheng=1;double aa=0;int s=0,b=0;intdouble 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;//+------------------------------------------------------------------+//| expert initialization function |//+------------------------------------------------------------------+int init(){//----//----return(0);}//+------------------------------------------------------------------+//| expert deinitialization function |//+------------------------------------------------------------------+int deinit(){//----//----return(0); }//+------------------------------------------------------------------+//| expert start function |//+------------------------------------------------------------------+int start(){//----MoneyManagement(); //资金管理macd(); //指标管理ma(); //指标管理zhangchang(); //战场管理buyme(); //买上sellme(); //买下xianshi(); //表明管理//----return(0); }//+------------------------------------------------------------------+void MoneyManagement() {lotstart=(AccountBalance()*lotab/10000); lots=lotstart;if(cheng==0){cheng=1;}CurrentBasket=AccountEquity()-AccountBalance(); /////////////////////////////////////////////////////////////////if(zijiguanli1){ LotMM = lots;}/////////////////////////////////////////////////////////////////if(zijiguanli2){if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lots*(OrdersTotal()*cheng)+ lotstart,2); }if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }}/////////////////////////////////////////////////////////////////if(zijiguanli3){if(s+b==0){aa=1;}if(s+b==1){aa=3;}if(s+b==2){aa=7;}if(s+b==3){aa=11;}if(s+b==4){aa=20;}if(s+b==5){aa=31;}if(s+b==6){aa=42;}if(s+b==7){aa=54;}if(s+b==8){aa=66;}if(s+b==9){aa=76;}if(s+b>=10){aa=66;}if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lotstart*aa,2); }if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }}/////////////////////////////////////////////////////////////////if(LotMMif(LotMM>LotsMax){LotMM=LotsMax;}}//end zijiguanli//+------------------------------------------------------------------+void macd() {//这边要写一部分东西}//+------------------------------------------------------------------+void ma(){ma1now = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma1now2 = iMA(NULL,0,ma10,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma2now = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma2now2 = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma1bnow = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_OPEN,0); ma2bnow = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_OPEN,0); }//+------------------------------------------------------------------+void zhangchang() {//这边要写一部分东西if(ma1now>ma2now&& ma1now2 && s+b==0){buyme(); }if(ma1now && ma1now2>ma2now2&& s+b==0){sellme(); }}//+------------------------------------------------------------------+void buyme(){if (TP==0) { TPP=0; } if(TP>0) { TPP=Ask+TP*Point; }if (SL==0) { SLL=0; } if(SL>0) { 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); }ticket=OrderSend(Symbol(),OP_SELL,LotMM,Bid,2,SLL, TPP,"M"+Period()+"",0,0,GreenYellow); return(0); }//+------------------------------------------------------------------+void buyme() {//这边要写一部分东西}//+------------------------------------------------------------------+void xianshi() {//这边要写一部分东西}//+------------------------------------------------------------------+/////end* 在buyme()和sellme()我们又发现新的词句TP,TPP,SL,SLL我们务必在#property上面加之他们不然会出错我已经加之去了上面的结果了你注意到了吗?* ok,这个EA可以用了当下你copy&press 去你的METAEDITORsave as 一个新的名字就可以了* 试一试,用一用告诉你,它肯定是“垃圾”EA由于是亏钱的EA
第六课-处理出错困难
* 假使你有做功课你会知道以上的EA依旧不能用由于出错了出错是常事没有什么了不起没有什么大事* 当你按在METAEDITOR按“编撰”时最以下会告诉你出错了按一按以下的出错他会告诉你在那里出错了第一:intdouble CurrentBasket=0;多了 int删掉 int 就可以了//int 是表明要“整数”比如:1,2,3,4...//double 表明要有小数点,比如:1.1,7.987.56.897.....* 之后你在按一下“编撰”他告诉你第二:ma1now2 = iMA(NULL,0,ma10,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma10,意思就是没有ma10这个新词句其实我们没有用到ma10是编撰错误不是ma10,是多了个0应当是ma1删掉 0 就可以了* 之后你在按一下“编撰”他告诉你第三:OrderSend(Symbol(),OP_BUY,LotMM,Ask,slip,SLL,TP P,"M"+Period()+"",0,0,Violet); 困难是slip应当是新的词句slip 是什么?听他们讲是滑点?管他由于我们不可以删掉slip所以在上方加之新的词句吧!比如:int slip=6;就可以了* 再来。ticket=OrderSend(Symbol(),OP_SELL,LotMM,Bid,2,SLL, TPP,"M"+Period()+"",0,0,GreenYellow); ticket?我们没有用到ticket所以可以删掉 ticket= 就可以了* 再来。他告诉你多了这个void buyme() {//这边要写一部分东西}由于已经有了的,哈哈和。是糊涂多了一个删掉 整句多余的buyme() 就可以了* 再来。0错误 0警示哈哈和。成功了恭喜你已经学会编撰EA了编撰EA就是处理困难
第七课-填写盈亏
上一回我们讲到-有赚25点就出场-假使亏的时机亏50点就出场这个还没有加之去编撰方法就是Take Profit=25Stop Loss=50我把他们简写成TP=25;SL=50;你想到了什么吗?对,这字眼很熟吧!记得吗?double TP=0,TPP=0,SL=0,SLL=0;我们改成double TP=25,TPP=0,SL=50,SLL=0;你发现吗?然而下注方面依旧有困难!其实是这EA没有分析什么是B什么是SB是buyS是sell速成班不必学会怎样写你只要copy&prss下面的子程式放进去就可以了我把它称为检查//////////////////////////////////////////void jiancha(){b=0;s=0;for (int cnt=0; cnt<=OrdersTotal(); cnt++){OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol()==Symbol() ){mode=OrderType(); LastOrderType=OrderType(); if (OrderType() == OP_SELL){ s++; LastPricesell=OrderOpenPrice(); }if (OrderType() == OP_BUY ){ b++; LastPricebuy=OrderOpenPrice(); }LastPrice=OrderOpenPrice(); if (OrderType()==OP_SELL) {OpenSells++;}if (OrderType()==OP_SELLSTOP) {OpenSellStops++;}if (OrderType()==OP_BUY) {OpenBuys++;}if (OrderType()==OP_BUYSTOP) {OpenBuyStops++;}}}}//end jiancha//////////////////////////////////////////////////要记得:在start那边也加入jiancha();如此就可以了。当我们按“编撰”会出错由于有了新的词句我们没有加在#property上面那边新的词句:modeLastOrderTypeLastPricesellLastPricebuyLastPriceOpenSellsOpenSellStopsOpenBuysOpenBuyStops我们更正如下:double mode=0;double LastOrderType;double LastPricesell;double LastPricebuy;double LastPrice;double OpenSells;double OpenSellStops;double OpenBuys;double OpenBuyStops;按“编撰”。0错误 0警示ok了按“终端”试一试效果怎样依旧不行依旧buy sell buy sell buy sell你知道什么事情发生了吗?跟你讲一个逻辑什么是主程式就是首要的程式什么是子程式就是不是首要的程式了解了这些当下一个困难,这些子程式MoneyManagement(); //资金管理macd(); //指标管理ma(); //指标管理zhangchang(); //战场管理buyme(); //买上sellme(); //买下xianshi(); //表明管理那些是不需要一直用的就不可以在主程式这里对啦!buyme(); //买上sellme(); //买下是有时用到,有时没有用所以我们删掉它当下这个EA可以正常的操作了其编撰程式如下:注意颜色部分的位置#property copyright "外汇联盟 www.FXunion.com QQ群144033"
#property link ""
extern double ma1=1,ma2=2;double ma1now,ma1now2,ma2now,ma2now2,ma1bnow,ma2bnow;////////////////////////extern string _资金管理_ ="任选一个";extern bool zijiguanli1= true;//false true、、extern bool zijiguanli2= false;//false true、、extern bool zijiguanli3= false;//false true、、///////////////////////////////////extern double cheng=1;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=25,TPP=0,SL=50,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(); //资金管理macd(); //指标管理ma(); //指标管理zhangchang(); //战场管理xianshi(); //表明管理//----return(0); }//+------------------------------------------------------------------+void jiancha(){b=0;s=0;for (int cnt=0; cnt<=OrdersTotal(); cnt++){OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol()==Symbol() ){mode=OrderType(); LastOrderType=OrderType(); if (OrderType() == OP_SELL){ s++; LastPricesell=OrderOpenPrice(); }if (OrderType() == OP_BUY ){ b++; LastPricebuy=OrderOpenPrice(); }LastPrice=OrderOpenPrice(); if (OrderType()==OP_SELL) {OpenSells++;}if (OrderType()==OP_SELLSTOP) {OpenSellStops++;}if (OrderType()==OP_BUY) {OpenBuys++;}if (OrderType()==OP_BUYSTOP) {OpenBuyStops++;}}}}//end jiancha//+------------------------------------------------------------------+void MoneyManagement() {lotstart=(AccountBalance()*lotab/10000); lots=lotstart;if(cheng==0){cheng=1;}CurrentBasket=AccountEquity()-AccountBalance(); /////////////////////////////////////////////////////////////////if(zijiguanli1){ LotMM = lots;}/////////////////////////////////////////////////////////////////if(zijiguanli2){if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lots*(OrdersTotal()*cheng)+ lotstart,2); }if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }}/////////////////////////////////////////////////////////////////if(zijiguanli3){if(s+b==0){aa=1;}if(s+b==1){aa=3;}if(s+b==2){aa=7;}if(s+b==3){aa=11;}if(s+b==4){aa=20;}if(s+b==5){aa=31;}if(s+b==6){aa=42;}if(s+b==7){aa=54;}if(s+b==8){aa=66;}if(s+b==9){aa=76;}if(s+b>=10){aa=66;}if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lotstart*aa,2); }if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }}/////////////////////////////////////////////////////////////////if(LotMMif(LotMM>LotsMax){LotMM=LotsMax;}}//end zijiguanli//+------------------------------------------------------------------+void macd() {//这边要写一部分东西}//+------------------------------------------------------------------+void ma(){ma1now = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma1now2 = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma2now = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,0); ma2now2 = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_CLOSE,1); ma1bnow = iMA(NULL,0,ma1,0,MODE_EMA,PR洲际交易所_OPEN,0); ma2bnow = iMA(NULL,0,ma2,0,MODE_EMA,PR洲际交易所_OPEN,0); }//+------------------------------------------------------------------+void zhangchang() {//这边要写一部分东西if(ma1now>ma2now&& ma1now2 && s+b==0){buyme(); }if(ma1now && ma1now2>ma2now2&& s+b==0){sellme(); }}//+------------------------------------------------------------------+void buyme(){if (TP==0) { TPP=0; } if(TP>0) { TPP=Ask+TP*Point; }if (SL==0) { SLL=0; } if(SL>0) { 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 xianshi() {//这边要写一部分东西}//+------------------------------------------------------------------+///////////////////////////////end