论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
前往
共 127 条
查看:29360回复:126
lhch
注册时间2006-05-05
[MT4-EA]顺势而为
楼主发表于:2008-05-09 10:57只看该作者倒序浏览
1楼 电梯直达
电梯直达
多年的做汇经验让我悟出一个道理,那就是顺势而为。怎么顺势,又如何判断呢?我用长期均线与短期均线结合。加了两个指标做了个模板,有经验的高手请编成EA程式提供大家一起用吧。编程要点:1.均线参数可以更改。2.可以设置止损止赢。3.可以用于任何周期。 暂提供默认参数:EMA:5 21 55 89 ADX默认 MACD默认。buy.GIFbuy.GIFsell.GIFsell.GIF
TK29帖子1楼右侧xm竖版广告90-240
个性签名

韬客社区www.talkfx.co

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
renkaixiu
注册时间2007-04-01
发表于:2008-05-09 12:20只看该作者
2楼
奇怪,怎么不能下载呢?
坚强的小强
注册时间2008-05-05
lhch
注册时间2006-05-05
楼主发表于:2008-05-10 04:10只看该作者
4楼
原来发的图设置了阅读权限buy.GIFbuy.GIFsell.GIFsell.GIF
雪天
注册时间2008-04-05
发表于:2008-05-19 10:07只看该作者
5楼
设置: 1、四条EMA(5、21、55、89)参数可设置 2、默认ADX指标(14) 3、默认MACD指标(图中似乎不是默认的5,34,5或者12,26,9) Long&Short 1、做空 开仓条件:5均线上探21均线受阻,跌破21均线阻力位确认(以柱体走完后均线的值为准) 过滤器: 1)ADX>25 2) MACD<0 平仓条件:5均线等于21均线 2、做多 开仓条件:5均线上破89均线 过滤器: 1)ADX>25 2) MACD>0 平仓条件:5均线等于89均线 资金管理: 1、手数与资金比例,每手都一样对待还是不同? 2、止损位置设置主要依据为55均线与89均线距离,做多时设置在55均线下方,做空时设置在89均线上方,具体值买入价-价差(55,89),或者卖出价+价差(55,89) 问题: 1、入场点的选择,是彻底遵循均线值突破为依据,还是需要等待回调一次确认?从图中看,做空的图是均线突破,而做多的图好像是等待回调确认 2、过滤条件的问题 1)ADX我不熟,粗略看了一下,是DMI的变体,表征市场动量,这个指标是不冲突的 2)MACD(20,54,8)这个过滤器,柱体表示的是20与54均线之差,仅仅依据这个作为顺势的判据吗?图中4条均线的趋势有无判断意义?请确认顺势的条件描述。 3、还是顺势的问题,只是单周期图的趋势?还是需要4-5倍周期中的趋势进行过滤? 最后: 我在做几个类似的趋势跟随系统,只是都没有做forwordTest,感谢您在这里发布自己的系统,希望这里也变得象FF那里大家很认真的讨论问题,我争取这个周末把EA的文档包含指标分析一起写完发给您处理,也可能食言因为近期事情很多,请留个联系的MSN或者邮箱, 我把代码和测试发到您那儿处理?或者可否直接传在这里? 我是新手,水平非常有限,希望更多的朋友不吝指导,大家将中国人的外汇论坛也搞的象FF一样平和而有价值。 盼复!!顺祝康安
lhch
注册时间2006-05-05
楼主发表于:2008-05-20 08:23只看该作者
6楼
谢谢!www.520fx.com将我的策略做成了EA,但我根据520fx论坛上的老师说的写了代码,发现只能做几回交易。你懂编程我将它贴上来你看看。具体要求请看http://bbs.520fx.com/viewthread.php?tid=5012&extra=page%3D1 //+------------------------------------------------------------------+ //| MT4_EA_制作速成班模板.mq4 | //| Copyright 2008, MT4_EA_制作速成班模板. | //| http://www.MT4_EA_制作速成班模板.net
| //+------------------------------------------------------------------+ #property copyright "MT4_EA_制作速成班模板" #property link "http://www.MT4_EA_制作速成班模板.net" //////////////////////// 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,i; double CurrentBasket=0; double LotMM=0; double lotstart=0; double LotsMax=100; extern double lotab=0.1; double lots=0; double TP=200,TPP=0,SL=60,SLL=0; int slip=6; ////////////////////////////////// double mode=0; double LastOrderType; double LastPricesell; double LastPricebuy; double LastPrice; double OpenSells; double OpenSellStops; double OpenBuys; double OpenBuyStops; double SLauto; double Stoploss; /////////////////////////////// int cnt; extern int TrailingStop=40; /////////////////////////////// string text=""; //////////////////////// extern double macd12_1=12, macd12_2=26, macd12_3=9; double macd12now; extern double ma1=1,ma5=5,ma21=21,ma55=55,ma89=89; double ma1now,ma5now,ma21now,ma55now,ma89now; extern double adx14=14; double adx14now; //////////////////////////// double BaoZhenJing; ////////////////////////////// int panduan; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- jiancha();//检查判断 资金管理(); macd指标管理(); ma指标管理(); adx指标管理(); zhangchang();//战场管理 xianshi();//显示管理 TrailingStop();//移动止赢 //---- 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 资金管理() { 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(LotMMLotsMax){LotMM=LotsMax;} }//end zijiguanli //+------------------------------------------------------------------+ void macd指标管理() { macd12now = iMACD(NULL,0,macd12_1,macd12_2,macd12_3,PRICE_CLOSE,MODE_MAIN,0); } //+------------------------------------------------------------------+ void adx指标管理() { //由MT4_EA_制作速成班学员asp_win提供 adx14now = iADX(NULL, 0, adx14, PRICE_CLOSE, MODE_MAIN, 0); } //+------------------------------------------------------------------+ void ma指标管理() { ma1now = iMA(NULL,0,ma1,0,MODE_EMA,PRICE_CLOSE,0); ma5now = iMA(NULL,0,ma5,0,MODE_EMA,PRICE_CLOSE,0); ma21now = iMA(NULL,0,ma21,0,MODE_EMA,PRICE_CLOSE,0); ma55now = iMA(NULL,0,ma55,0,MODE_EMA,PRICE_CLOSE,0); ma89now = iMA(NULL,0,ma89,0,MODE_EMA,PRICE_CLOSE,0); } //+------------------------------------------------------------------+ void zhangchang() { //--- 如果开仓保证金超过上限,则返还不交易。 ------------------ if( AccountMargin() / (AccountMargin() + AccountFreeMargin()) >= 1 ) { return(0); } BaoZhenJing = MarketInfo( Symbol(), MODE_MARGINREQUIRED); // 一个标准手需保证金金额。 BaoZhenJing = BaoZhenJing * LotMM ; // 下单需用的保证金 if( (AccountMargin()+BaoZhenJing) / (AccountMargin()+AccountFreeMargin()) >= 1 ) { return(0); } //--------------------------------------------------------------------- //这边编写策略(下面if(s+b==100)暂时是故意这样写的,其实是为了防止出错) if(s+b==0){sellme();buyme();closebuy();closesell();} /////第一部分///////////////////// if(s+b==0 //判断没有交易才能判断1 && panduan==0 //判断0才能判断1 && ma5now>ma55now //ma5大过ma55才能判断1 && ma5now25 //判断ADX14大过25才能交易 && macd12now<0 //判断macd12小过0才能交易 && Close[0]ma89now && adx14now>25 && macd12now>0 && Close[0]>Open[0] //判断是在上升 ){buyme();panduan=0;} //////第四部分///////////////////// if(ma89now>ma55now){SLauto=(ma89now-ma55now)/Point;} //止损点数计算[//老师我不知道这个是什么原理,也判断不了是否有错] if(ma89nowStoploss){SL=SLauto;} //如果判断自动止损大一点,就选自动止损 if(SLautoma21now ){closesell();} if(s+b==1 && ma5now0) { 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); } //+------------------------------------------------------------------+ //平倉持有的買單 由MT4_EA_制作速成班学员asp_win提供 void closebuy() { if(s+b==1 && ma5nowma21now ); } //+------------------------------------------------------------------+ void xianshi() { string name_8 = "xianshi1"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8, "伺服器时间::"+TimeToStr(CurTime( ))+"", 13, "Arial", White); ObjectSet(name_8, OBJPROP_CORNER, 0); ObjectSet(name_8, OBJPROP_XDISTANCE, 200); ObjectSet(name_8, OBJPROP_YDISTANCE, 5); text="EA制作速成班"; name_8 = "xianshi2"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8, ""+text+"", 15, "Arial", Yellow); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 5); name_8 = "Lableyeddrice1"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8, "M"+Period()+" 货币 "+Symbol()+"", 10, "Arial", Silver); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 130); ObjectSet(name_8, OBJPROP_YDISTANCE, 32); //////这个显示上方 name_8 = "LableCurPrice2"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr(Ask, Digits)+"::买上", 15, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 30); //////这个显示下方 name_8 = "Lab345rPrice3"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr(Bid, Digits)+"::卖下", 15, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 50); name_8 = "Acc87lance"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountBalance(), 2)+"::账面资金", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 70); name_8 = "LableC5rice6"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountEquity(), 2)+"::净值资金", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 90); name_8 = "Labl456rice6"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountMargin(), 2)+"::保证资金", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 110); name_8 = "Labl4hcjce6"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountFreeMargin(), 2)+"::可用资金", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 130); name_8 = "Accvf7lance"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountProfit(), 2)+"::账面盈亏", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 150); //我们可以无限的加 } //+------------------------------------------------------------------+ /////////////////////// 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()
szscwy
注册时间2005-08-12
雪天
注册时间2008-04-05
发表于:2008-05-21 15:02只看该作者
8楼
//+------------------------------------------------------------------+ //| MT4_EA_制作速成班模板.mq4 | //| Copyright 2008, MT4_EA_制作速成班模板. | //| http://www.MT4_EA_制作速成班模板.net | //+------------------------------------------------------------------+ #property copyright "MT4_EA_制作速成班模板" #property link "http://www.MT4_EA_制作速成班模板.net" //////////////////////// 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,i; double CurrentBasket=0; double LotMM=0; double lotstart=0; double LotsMax=100; extern double lotab=0.1; double lots=0; double TP=200,TPP=0,SL=60,SLL=0; int slip=6; ////////////////////////////////// double mode=0; double LastOrderType; double LastPricesell; double LastPricebuy; double LastPrice; double OpenSells; double OpenSellStops; double OpenBuys; double OpenBuyStops; double SLauto; double Stoploss; /////////////////////////////// int cnt; extern int TrailingStop=40; /////////////////////////////// string text=""; //////////////////////// extern double macd12_1=12, macd12_2=26, macd12_3=9; double macd12now; extern double ma1=1,ma5=5,ma21=21,ma55=55,ma89=89; double ma1now,ma5now,ma21now,ma55now,ma89now; extern double adx14=14; double adx14now; //////////////////////////// double BaoZhenJing; ////////////////////////////// int panduan; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- jiancha();//检查判断 资金管理(); macd指标管理(); ma指标管理(); adx指标管理(); zhangchang();//战场管理 xianshi();//显示管理 TrailingStop();//移动止赢 //---- 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 资金管理() { 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(LotMMLotsMax){LotMM=LotsMax;} }//end zijiguanli //+------------------------------------------------------------------+ void macd指标管理() { macd12now = iMACD(NULL,0,macd12_1,macd12_2,macd12_3,PRICE_CLOSE,MODE_MAIN,0); } //+------------------------------------------------------------------+ void adx指标管理() { //由MT4_EA_制作速成班学员asp_win提供 adx14now = iADX(NULL, 0, adx14, PRICE_CLOSE, MODE_MAIN, 0); } //+------------------------------------------------------------------+ void ma指标管理() { ma1now = iMA(NULL,0,ma1,0,MODE_EMA,PRICE_CLOSE,0); ma5now = iMA(NULL,0,ma5,0,MODE_EMA,PRICE_CLOSE,0); ma21now = iMA(NULL,0,ma21,0,MODE_EMA,PRICE_CLOSE,0); ma55now = iMA(NULL,0,ma55,0,MODE_EMA,PRICE_CLOSE,0); ma89now = iMA(NULL,0,ma89,0,MODE_EMA,PRICE_CLOSE,0); } //+------------------------------------------------------------------+ void zhangchang() { //--- 如果开仓保证金超过上限,则返还不交易。 ------------------ if( AccountMargin() / (AccountMargin() + AccountFreeMargin()) >= 1 ) { return(0); } BaoZhenJing = MarketInfo( Symbol(), MODE_MARGINREQUIRED); // 一个标准手需保证金金额。 BaoZhenJing = BaoZhenJing * LotMM ; // 下单需用的保证金 if( (AccountMargin()+BaoZhenJing) / (AccountMargin()+AccountFreeMargin()) >= 1 ) { return(0); } //--------------------------------------------------------------------- //这边编写策略(下面if(s+b==100)暂时是故意这样写的,其实是为了防止出错) //if(s+b==0){sellme();buyme();closebuy();closesell();} /////第一部分///////////////////// if(s+b==0 //判断没有交易才能判断1 && panduan==0 //判断0才能判断1 && ma5now>ma55now //ma5大过ma55才能判断1 && ma5now25 //判断ADX14大过25才能交易 && macd12now<0 //判断macd12小过0才能交易 && Close[0]ma89now && adx14now>25 && macd12now>0 && Close[0]>Open[0] //判断是在上升 ){buyme();panduan=0;} //////第四部分///////////////////// if(ma89now>ma55now){SLauto=(ma89now-ma55now)/Point;} //止损点数计算[//老师我不知道这个是什么原理,也判断不了是否有错] if(ma89nowStoploss){SL=SLauto;} //如果判断自动止损大一点,就选自动止损 if(SLautoma21now ){closesell();} if(s+b==1 && ma5now0) { 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); } //+------------------------------------------------------------------+ //平倉持有的買單 由MT4_EA_制作速成班学员asp_win提供 void closebuy() { if(s+b==1&& ma5nowma21now); CheckForClose(1); } //+------------------------------------------------------------------+ void xianshi() { string name_8 = "xianshi1"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8, "伺服器时间::"+TimeToStr(CurTime( ))+"", 13, "Arial", White); ObjectSet(name_8, OBJPROP_CORNER, 0); ObjectSet(name_8, OBJPROP_XDISTANCE, 200); ObjectSet(name_8, OBJPROP_YDISTANCE, 5); text="EA制作速成班"; name_8 = "xianshi2"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8, ""+text+"", 15, "Arial", Yellow); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 5); name_8 = "Lableyeddrice1"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8, "M"+Period()+" 货币 "+Symbol()+"", 10, "Arial", Silver); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 130); ObjectSet(name_8, OBJPROP_YDISTANCE, 32); //////这个显示上方 name_8 = "LableCurPrice2"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr(Ask, Digits)+"::买上", 15, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 30); //////这个显示下方 name_8 = "Lab345rPrice3"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr(Bid, Digits)+"::卖下", 15, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 50); name_8 = "Acc87lance"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountBalance(), 2)+"::账面资金", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 70); name_8 = "LableC5rice6"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountEquity(), 2)+"::净值资金", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 90); name_8 = "Labl456rice6"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountMargin(), 2)+"::保证资金", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 110); name_8 = "Labl4hcjce6"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountFreeMargin(), 2)+"::可用资金", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 130); name_8 = "Accvf7lance"; ObjectDelete(name_8); ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0); ObjectSetText(name_8,""+DoubleToStr( AccountProfit(), 2)+"::账面盈亏", 13, "Arial", Lime); ObjectSet(name_8, OBJPROP_CORNER, 1); ObjectSet(name_8, OBJPROP_XDISTANCE, 15); ObjectSet(name_8, OBJPROP_YDISTANCE, 150); //我们可以无限的加 } //+------------------------------------------------------------------+ /////////////////////// 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()
个性签名

韬客社区www.talkfx.co

广告
论坛谏言--外汇交易不应是你投资的全部,交易外汇也不应是你生活的全部
雪天
注册时间2008-04-05
发表于:2008-05-21 15:17只看该作者
9楼
简单修改后的代码 1、程序里面资金管理有点问题,没修改,你设置成50000的初始资金会好很多 2、没法平仓是因为过去的时候你里面没有平仓的程序,已经简单加入 3、你的开仓信号和平仓信号之间的判断条件好像有些含混,而且程序里面也有些问题,s+b==0就连做买入卖出平仓的那句我就没看懂,屏蔽掉似乎好多了。 4、建议使用MAGICNUM,来表示你自动交易的单子,这样子可以将EA进行模拟测试或者真正投入使用 5、关于指标的一点建议,你现在系统中使用的都是当前bar的指标值,而当前bar没有走完之前,指标是可变的,所以使用指标的系统有两种选择,保守点的是使用上一个bar的指标值,激进点的是使用当前指标值。顺势交易系统似乎倾向于前者,信号确认后再进场。 依据测试结果看,你现在这个EA的出入场条件似乎有些冲突问题,没有仔细看,因为还要抓紧洗了睡明早出差:( [ 本帖最后由 雪天 于 2008-5-21 23:19 编辑 ]
lhch
注册时间2006-05-05
楼主发表于:2008-05-22 04:57只看该作者
10楼
这个交易系统是跟隧道交易系统的原理是一样的。只不过信号更准确一些。我用的参数跟它的不同。我发上来供大家参考
隧道交易系统说明书中文版.rar
雪天
注册时间2008-04-05
发表于:2008-05-22 13:20只看该作者
11楼
//+------------------------------------------------------------------+ //| "Anubis".mq4 | //| compiled for | //| | //| Automated | //| Trading Championship | //| 2006 | //+------------------------------------------------------------------+ #property copyright "Copyright c 2006, Andrew Tikhonov" #include //---- //单子的标识符号,如果有多个EA运行,请修改成不同的值 #define TRENDMAGIC 23061234 #define FLATMAGIC 23065678 //标识多空信号的宏 #define UNDEF 0 #define LONG 1 #define SHORT -1 //输入参数 extern string expName ="TalkForex.lhch"; //资金管理参数 extern double Lots =1; //默认手数 extern int Stoploss =100; //止损 extern int TakeProfit=100; //止赢 extern int breakeven =65; //BE止损设置,如设置为65,则盈利65点后,将止损设置为入场点 extern double RFactor =0.6; //资金风险系数,用来优化每次入场手数 //信号参数 //ADX参数 extern int P_ADX =14; //MA参数 extern int P_1 =1; extern int P_2 =5; extern int P_3 =21; extern int P_4 =55; extern int P_5 =89; //MACD参数 extern int P_FastEMA =12; extern int P_SlowEMA =26; extern int P_Signal =9; //最大多空单数 int shortOrders=2; int longOrders =2; //记录多空开仓的柱体位置 int openLongBar=0; int openShortBar=0; //记录最后多空开仓的价位 double lastLongPrice; double lastShortPrice; datetime expTime=0; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void init() { } //+------------------------------------------------------------------+ //| 当前EA的多单空单数目,使用ref类型参数 | //+------------------------------------------------------------------+ bool numOrders(int & longs, int & shorts) { int i; //---- longs =0; shorts=0; for(i=OrdersTotal()-1; i>=0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber()==FLATMAGIC) { if (OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT) { longs++; } if (OrderType()==OP_SELL || OrderType()==OP_SELLLIMIT) { shorts++; } } } } //+------------------------------------------------------------------+ //| 检测仓位,如果符合BE止损,进行设置保持仓位不亏损 | //+------------------------------------------------------------------+ void setFlatBreakeven() { int i; if (OrdersTotal()==0) return; for(i=OrdersTotal()-1; i>=0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType()==OP_BUY && OrderMagicNumber()==FLATMAGIC) { if (Bid-breakeven*Point>OrderOpenPrice() && OrderOpenPrice()>OrderStopLoss()) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Aqua); return; } } if(OrderType()==OP_SELL && OrderMagicNumber()==FLATMAGIC) { if (Ask+breakeven*Point 22000) { mylots=mylots * 3.2; } else if (AccountBalance() > 14000) { mylots=mylots * 2; } //---- return(NormalizeDouble(mylots * factor, 1)); //return(1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool checkFreeMargin() { double lotsize =MarketInfo(Symbol(),MODE_LOTSIZE); double leverage=AccountLeverage(); double minlot =MarketInfo(Symbol(),MODE_MINLOT); //---- if (AccountFreeMargin() < (Ask * lotsize/leverage * minlot)) { Print ("--- NOT ENOUGH MONEY ---"); return(false); } return(true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start_flatSystem() { //是否当前柱体的第一次运行此函数 if (expTime!=Time[0]) { expTime=Time[0]; } else { return; } //检查资金 if (!checkFreeMargin()) { return(0); } //if (!IsConnected()) { Print("not connected!"); } //连接 //if (IsStopped()) { Print("stopped!"); } //停止 if (!IsTradeAllowed()) { Print("Trade NOT allowed!"); } //允许交易 //if (IsTradeContextBusy()) { Print("Trade context busy!"); }//服务器忙 //----信号变量 int i; //double iCCI0; double dADX; double dMA1,dMA2,dMA3,dMA4,dMA5; double dMACD; //----仓位管理变量 int openLong =0; int openShort=0; int openCmd=UNDEF; int numLongs; int numShorts; //---- numOrders(numLongs, numShorts); //double stDev=iStdDev(Symbol(),PERIOD_H4,20,0,MODE_SMA,PRICE_CLOSE,1); dADX = iADX(NULL, 0, P_ADX, PRICE_CLOSE, MODE_MAIN, 1); dMACD = iMACD(NULL,0,P_FastEMA,P_SlowEMA,P_Signal,PRICE_CLOSE,MODE_MAIN,1); dMA1 = iMA(NULL,0,P_1,0,MODE_EMA,PRICE_CLOSE,1); dMA2 = iMA(NULL,0,P_2,0,MODE_EMA,PRICE_CLOSE,1); dMA3 = iMA(NULL,0,P_3,0,MODE_EMA,PRICE_CLOSE,1); dMA4 = iMA(NULL,0,P_4,0,MODE_EMA,PRICE_CLOSE,1); dMA5 = iMA(NULL,0,P_5,0,MODE_EMA,PRICE_CLOSE,1); //止损位 double sl = MathMax(Stoploss,(MathAbs(dMA4-dMA5)/Point)); sl *= Point; double take = TakeProfit*Point; //开仓方向信号 if(dMA225 && dMACD<0 ) { openCmd=SHORT; } if(dMA2>dMA5 && dADX>25 && dMACD>0 ) { openCmd=LONG; } if (numShorts==0) { lastShortPrice=0 ;} if (numLongs ==0) { lastLongPrice=0 ;} double myprice; //入场 if (openCmd==SHORT && openShortBar!=Bars && numShorts < shortOrders) { if (MathAbs(Ask-lastShortPrice) > 20*Point) { //RefreshRates(); OrderSend(Symbol(),OP_SELL,getLots(),Bid,3,Bid+sl,Bid-take,expName,FLATMAGIC,0,Blue); openShortBar=Bars; lastShortPrice=Ask; } } if (openCmd==LONG && openLongBar!=Bars && numLongs < longOrders) { if (MathAbs(Ask-lastLongPrice) > 20*Point) { //RefreshRates(); //---- OrderSend(Symbol(),OP_BUY,getLots(),Ask,3,Ask-sl,Ask+take,expName,FLATMAGIC,0,Red); openLongBar=Bars; lastLongPrice=Ask; } } //BE止损 setFlatBreakeven(); //平仓 if (OrdersTotal() > 0) { for(i=OrdersTotal()-1; i>=0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber()==FLATMAGIC) { if(OrderType()==OP_BUY) { if(dMA2dMA3) OrderClose(OrderTicket(),OrderLots(),Ask,3,Green); } } } } //---- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { start_flatSystem(); return(0); } //+------------------------------------------------------------------+
雪天
注册时间2008-04-05
发表于:2008-05-22 13:26只看该作者
12楼
依据06champnion貌似名列前几的一位EA修改而来,我测试了一下,感觉你的出入场条件有问题,因为胜率太低,当然修改止损止赢和BE后胜率提高了,但是无法达到80%胜率的EA恐怕是难以生存的。您自测一下吧,如果只想做一单,可以修改最大多空单数。如果不想做资金配置优化,可以在getlots()函数中把最后一行的注释放开,上一行屏蔽掉。 我在mql4网站查adx的时候,有篇文章说使用MA21与ADX是否大于20来做EA,希望能有帮助。 http://codebase.mql4.com/3528
雪天
注册时间2008-04-05
发表于:2008-05-22 13:27只看该作者
13楼
而且您的出入场条件,似乎没有考虑顺势的因素,也没有考虑指标值升降的问题
个性签名

韬客社区www.talkfx.co

雪天
注册时间2008-04-05
发表于:2008-05-22 15:28只看该作者
14楼
刚刚根据您发的那个隧道交易做了个EA,效果还说的过去,就是小赢大亏:(总体胜率还好 //+------------------------------------------------------------------+ //| MACD Sample.mq4 | //| Copyright ?2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #define MAGICNUMFIRST 2008052201 #define MAGICNUMSECOND 2008052202 #define TOTALORDERS 2 extern double TPFirst = 55; extern double TPSecond = 377; extern double Lots = 1; extern double TrailingStop = 30; bool bCanBuy = true; bool bCanSell= true; datetime expTime=0; bool numOrders(int & longs, int & shorts) { int i; //---- longs =0; shorts=0; for(i=OrdersTotal()-1; i>=0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber()==MAGICNUMFIRST || OrderMagicNumber()==MAGICNUMSECOND) { if (OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT) { longs++; } if (OrderType()==OP_SELL || OrderType()==OP_SELLLIMIT) { shorts++; } } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { //是否当前柱体的第一次运行此函数 if (expTime!=Time[0]) { expTime=Time[0]; } else { return; } double dEMA144Current,dEMA169Current,dEMA12Current; double dEMA144Previous,dEMA169Previous,dEMA12Previous; double dMAX,dMIN,dSL; int cnt, ticket, total; if(Bars<180) { Print("bars less than 100"); return(0); } // to simplify the coding and speed up access // data are put into internal variables dEMA144Current = iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,1); dEMA169Current = iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,1); dEMA12Current = iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,1); dEMA144Previous = iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,2); dEMA169Previous = iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,2); dEMA12Previous = iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,2); dMAX = MathMax(dEMA144Current,dEMA169Current); dMIN = MathMin(dEMA144Current,dEMA169Current); dSL = MathAbs(dEMA144Current-dEMA169Current); int numLongs,numShorts; numOrders(numLongs,numShorts); // no opened orders identified if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } // check for long position (BUY) possibility if(Ask > dMAX+20*Point && numLongs == 0 && dEMA144Current > dEMA144Previous ) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,dMIN,Ask+TPFirst*Point,"macd sample",MAGICNUMFIRST,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); /** ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,dMIN,0,"macd sample",MAGICNUMSECOND,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); **/ return(0); } // check for short position (SELL) possibility if(Bid < dMIN-20*Point && numShorts == 0&& dEMA144Current < dEMA144Previous ) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,dMAX,Bid-TPFirst*Point,"macd sample",MAGICNUMFIRST,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); /* ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,dMAX,0,"macd sample",MAGICNUMFIRST,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); */ return(0); } // it is important to enter the market correctly, // but it is more important to exit it correctly... for(cnt=0;cnt0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()dMAX) { 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.
雪天
注册时间2008-04-05
发表于:2008-05-22 15:30只看该作者
15楼
还有更多隧道交易的资料或者原版出处吗?如果破隧道只做一次止赢55点的交易,胜率接近100%了
雪天
注册时间2008-04-05
发表于:2008-05-22 15:39只看该作者
16楼
又加入了144均线与169均线上下位置的过滤条件,EUR/USD 1H图,胜率到72%了,平均亏损情况好了很多 //+------------------------------------------------------------------+ //| MACD Sample.mq4 | //| Copyright ?2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #define MAGICNUMFIRST 2008052201 #define MAGICNUMSECOND 2008052202 #define TOTALORDERS 2 extern double TPFirst = 55; extern double TPSecond = 377; extern double Lots = 1; extern double TrailingStop = 30; bool bCanBuy = true; bool bCanSell= true; datetime expTime=0; bool numOrders(int & longs, int & shorts) { int i; //---- longs =0; shorts=0; for(i=OrdersTotal()-1; i>=0; i--) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber()==MAGICNUMFIRST || OrderMagicNumber()==MAGICNUMSECOND) { if (OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT) { longs++; } if (OrderType()==OP_SELL || OrderType()==OP_SELLLIMIT) { shorts++; } } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { //是否当前柱体的第一次运行此函数 if (expTime!=Time[0]) { expTime=Time[0]; } else { return; } double dEMA144Current,dEMA169Current,dEMA12Current; double dEMA144Previous,dEMA169Previous,dEMA12Previous; double dMAX,dMIN,dSL; int cnt, ticket, total; if(Bars<180) { Print("bars less than 100"); return(0); } // to simplify the coding and speed up access // data are put into internal variables dEMA144Current = iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,1); dEMA169Current = iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,1); dEMA12Current = iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,1); dEMA144Previous = iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,2); dEMA169Previous = iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,2); dEMA12Previous = iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,2); dMAX = MathMax(dEMA144Current,dEMA169Current); dMIN = MathMin(dEMA144Current,dEMA169Current); dSL = MathAbs(dEMA144Current-dEMA169Current); int numLongs,numShorts; numOrders(numLongs,numShorts); // no opened orders identified if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } // check for long position (BUY) possibility if(Ask > dMAX+20*Point && numLongs == 0 && dEMA144Current > dEMA144Previous && dEMA144Current>dEMA169Current ) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,dMIN,Ask+TPFirst*Point,"macd sample",MAGICNUMFIRST,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); /** ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,dMIN,0,"macd sample",MAGICNUMSECOND,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); **/ return(0); } // check for short position (SELL) possibility if(Bid < dMIN-20*Point && numShorts == 0&& dEMA144Current < dEMA144Previous && dEMA144Current0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); /* ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,dMAX,0,"macd sample",MAGICNUMFIRST,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); */ return(0); } // it is important to enter the market correctly, // but it is more important to exit it correctly... for(cnt=0;cnt0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()dMAX) { 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.
雪天
注册时间2008-04-05
发表于:2008-05-22 15:41只看该作者
17楼
如何发文件,周末如果有时间的话整理一下传上来
个性签名

韬客社区www.talkfx.co

lhch
注册时间2006-05-05
楼主发表于:2008-05-22 16:57只看该作者
18楼
将我的顺势而为里的ADX和AO指标加入去做为过滤条件。遂道选89与144.
个性签名

韬客社区www.talkfx.co

雪天
注册时间2008-04-05
发表于:2008-05-23 09:01只看该作者
19楼
依据下面这段话 “Step 5.As the market trades in your direction, you take partial profits at the successive fib numbers respectively, with the final portion of your position left on until one of the following conditons occur: 1) market hits the last fib number [377 pips] from the ema's, or 2) the market eventually comes back to the tunnel and violates the other side. 第5步:当市场按你交易方向进行时,你按费纳滋数列逐一兑现部分利润离场,留下部分最后一部分头寸直到出现以下情况时再结清:1)K线碰到最后一个费纳滋数字(377点)或2)K线最终回到了隧道碰并且到了另一边。 Example: GBP/USD is trading at 1.8500. The ema's are as follows: 144- 1.8494, 169- 1.8512. The market breaks 1.8494, and you sell at 1.8492. Your stop and reverse is now at 1.8512. Over the following hours, market starts to go down. 40 minutes after you put position on, cable is at 1.8440. You can use for computation purposes either tunnel boundary or the median of the tunnel. Ema's are still the same, so if you use the median, 55 from 1.8503 is 1.8448. You should have taken part of the position off at 1.8448. Market does nothing rest of day. Stop can be moved down to protect position or left alone at tunnel. You are now looking for price to be 89 pips away from the ema's. Since 55 was already passed, it no longer concerns us in this cycle. A couple of days later, cable is at 1.8300 and the median of ema's is 1.8410 [1.8400 - 1.8420]. You should be out of another portion of the position at 1.8321. Market bottoms here and in the next 2 hours, cable screams to 1.8535. Your remaining short position is covered at upper tunnel boundary of 1.8420, and you are now long from this point as well. Since you are long, you would now take partial profits at 1.8475 and 1.8509. 例如:GBP/USD 在1.8500位置交易,EMA状况如下:ema(144)-1.8494,EMA(169)-1.8512.K线跌破1.8494,你就在1.8492位置作空,你设定的止损或反转点现在就是1.8512。在接下来的几小时,市场开始向下走,40分钟你开仓后,到了1.8440。你可以用计算机计算结果隧道边缘或者隧道中了。ema还是一样的,所以如果你用隧道中央,从1.8503到1.8448是55点,你可以在1.8448位置了解部分头寸。接下来一天里市场无所作为,止损可以移动到保护头寸或任由其在隧道内。现在你寻求由ema下来的89点的价位了。由于55点已经过了,我们不再关心这个循环了。几天以后,到了1.8300的位置,中线ema是1.8410(1.8410-1.8420)。你必须在1.8321位置出来另一部分头寸。这就是市场的底了,2小时后,涨到1.8535。你的剩余头寸在上轨上缘1.8420位置了,现在你最好做多。由于你现在做多,你可以将空头头寸在1.8475或1.8509结回部分利润。This is a fairly typical example. " 确定平仓和止损位置的依据,因此我想,隧道中间线与价格之间是否存在fibo数字的回调与破位呢,于是写了个指标进行测试,居然还真的存在这种关系,是个不错的复合指标。 蓝色中线是隧道中间线,红色是汇价与中间线之差的点数,黄色是红色的9数据平均,类似KDJ的看法。 其他fibo线已经标上,时间无多,还有事情处理,请查收代码
个性签名

韬客社区www.talkfx.co

雪天
注册时间2008-04-05
发表于:2008-05-23 09:05只看该作者
20楼
//+------------------------------------------------------------------+ //| IndTunnelOS.mq4 | //| Snowman | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Snowman" #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 CornflowerBlue #property indicator_color3 Yellow #property indicator_level1 34 #property indicator_level2 55 #property indicator_level3 89 #property indicator_level4 144 #property indicator_level5 -34 #property indicator_level6 -55 #property indicator_level7 -89 #property indicator_level8 -144 //---- input parameters for EMA extern int ExtParam1=144; extern int ExtParam2=169; extern int SignalParam=9; //---- buffers double ExtMapBuffer1; double ExtMapBuffer2; double ExtMapBuffer3; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(3); SetIndexStyle(0,DRAW_LINE); SetIndexDrawBegin(0,ExtParam2); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE); SetIndexDrawBegin(1,ExtParam2); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE); SetIndexDrawBegin(2,ExtParam2+SignalParam); SetIndexBuffer(2,ExtMapBuffer3); SetIndexLabel(0,"S"); SetIndexLabel(1,"Signal"); SetIndexLabel(2,"SlowSignal"); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; double dEMA1,dEMA2,dMid; int counted_bars=IndicatorCounted(); //---- check for possible errors //if(counted_bars<0) return(0); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- for(int i=0; i
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
前往
共 127 条

本站免责声明:

1、本站所有广告及宣传信息均与韬客无关,如需投资请依法自行决定是否投资、斟酌资金安全及交易亏损风险;

2、韬客是独立的、仅为投资者提供交流的平台,网友发布信息不代表韬客的观点与意思表示,所有因网友发布的信息而造成的任何法律后果、风险与责任,均与韬客无关;

3、金融交易存在极高法律风险,未必适合所有投资者,请不要轻信任何高额投资收益的诱导而贸然投资;投资保证金交易导致的损失可能超过您投入的资金和预期。请您考虑自身的投资经验及风险承担能力,进行合法、理性投资;

4、所有投资者的交易帐户应仅限本人使用,不应交由第三方操作,对于任何接受第三方喊单、操盘、理财等操作的投资和交易,由此导致的任何风险、亏损及责任由投资者个人自行承担;

5、韬客不隶属于任何券商平台,亦不受任何第三方控制,韬客不邀约客户投资任何保证金交易,不接触亦不涉及投资者的任何资金及账户信息,不代理任何交易操盘行为,不向客户推荐任何券商平台,亦不存在其他任何推荐行为。投资者应自行选择券商平台,券商平台的任何行为均与韬客无关。投资者注册及使用韬客即表示其接受和认可上述声明,并自行承担法律风险。

版权所有:韬客外汇论坛 www.talkfx.com 联络我们:[email protected]