PDA

View Full Version : 我需要幫助使我的MoneyMaker EA運行得更快



sltayas
03-12-2007 13:30, 01:30 PM
嘿,我對一些非常好的metatrader程序員有一個問題。在我的EA中,我根據功能在時間幀之間切換。如果EA確定我應該使用15分鐘的時間幀,那麼它會在start()之後立即調用RangePrefetch()。如果我應該使用1小時圖表,那麼EA在start()之後立即調用TrendPrefetch()。除了句點之外,RangePrefetch()和TrendPrefetch()都是完全相同的,它們是在init()之後定義的。

問題是由於在時間範圍之間來回切換,測試和優化它需要相當長的時間。所以我想知道是否有某種方法可以重新排列代碼或者只是將代碼編碼為更有效的方式,因此它運行得更快。非常感謝。

插入代碼extern double JumpWidth_Percen = 0.25;字符串趨勢,買,賣,TradeComm; double Close1,Close2,Close3,Close4,Close5,Close6,Open1,Open2,Open3,Open4,Open5,Open6,Fast1,Fast2,Fast3,Fast4,Fast5,Fast6,Slow1,Slow2,Slow3,Slow4,Slow5,Slow6,Average ,FastW,Currency_momentumA,Currency_momentumB,Currency_momentumC,Trend_momentumFastA,Trend_momentumFastB,Trend_momentumFastC,Trend_momentumFastD,Trend_momentumSlowA,Trend_momentumSlowB,Width1,Width2,Width3,Width4,Width5,Width6,WidthW1,WidthW2,WidthW3,WidthW4,WidthW5,WidthW6,FastTrend,SlowTrend; int Trendd,MaxpipfromEMA,Ranging,RangingS,TFTime; void TrendPreFetch(){Average = iMA(NULL,PERIOD_H1,3,0,MODE_EMA,PRICE_CLOSE,1); FastW = IMA(NULL,PERIOD_H1,fastma * 3.8,0,MODE_EMA,PRICE_CLOSE,1); Currency_momentumA = iCustom而(NULL,PERIOD_H1,OSMAMA,4,6-,currency_momentum,1,currency_momentum,0,1); Currency_momentumB = iCustom而(NULL,PERIOD_H1,OSMAMA,4,6-,currency_momentum,1,currency_momentum,1,1); Currency_momentumC = iCustom而(NULL,PERIOD_H1,OSMAMA,4,6-,currency_momentum,1,currency_momentum,0,5); Trend_momentumFastA = iCustom而(NULL,PERIOD_H1,OSMAMA,4,6-,trend_momentum,1,trend_momentum,0,1); Trend_momentumFastB = iCustom而(NULL,PERIOD_H1,OSMAMA,4,6-,trend_momentum,1,trend_momentum,0,2); Trend_momentumFastC = iCustom而(NULL,PERIOD_H1,OSMAMA,4,6-,trend_momentum,1,trend_momentum,0,3); Trend_momentumFastD = iCustom而(NULL,PERIOD_H1,OSMAMA,4,6-,trend_momentum,1,trend_momentum,1,1); Trend_momentumSlowA = iCustom而(NULL,PERIOD_H1,OSMAMA,6,8,slowma * 3,* currency_momentum 3,currency_momentum * 3,0,1); Trend_momentumSlowB = iCustom而(NULL,PERIOD_H1,OSMAMA,6,8,slowma * 3,* currency_momentum 3,currency_momentum * 3,0,5); void RangePreFetch(){Average = iMA(NULL,PERIOD_M15,3,0,MODE_EMA,PRICE_CLOSE,1); FastW = IMA(NULL,PERIOD_M15,fastma * 3.8,0,MODE_EMA,PRICE_CLOSE,1); Currency_momentumA = iCustom而(NULL,PERIOD_M15,OSMAMA,4,6-,currency_momentum,1,currency_momentum,0,1); Currency_momentumB = iCustom而(NULL,PERIOD_M15,OSMAMA,4,6-,currency_momentum,1,currency_momentum,1,1); Currency_momentumC = iCustom而(NULL,PERIOD_M15,OSMAMA,4,6-,currency_momentum,1,currency_momentum,0,5); Trend_momentumFastA = iCustom而(NULL,PERIOD_M15,OSMAMA,4,6-,trend_momentum,1,trend_momentum,0,1); Trend_momentumFastB = iCustom而(NULL,PERIOD_M15,OSMAMA,4,6-,trend_momentum,1,trend_momentum,0,2); Trend_momentumFastC = iCustom而(NULL,PERIOD_M15,OSMAMA,4,6-,trend_momentum,1,trend_momentum,0,3); Trend_momentumFastD = iCustom而(NULL,PERIOD_M15,OSMAMA,4,6-,trend_momentum,1,trend_momentum,1,1); Trend_momentumSlowA = iCustom而(NULL,PERIOD_M15,OSMAMA,6,8,slowma * 3,* currency_momentum 3,currency_momentum * 3,0,1); Trend_momentumSlowB = iCustom而(NULL,PERIOD_M15,OSMAMA,6,8,slowma * 3,* currency_momentum 3,currency_momentum * 3,0,5);} int start(){double Averagepips,Opentime,Stopip; int i,open,Spike,SpikeW,Buyjump,Selljump,BuyjumpR,SelljumpR,Ticket,Cnt,Can; double SlowTrend = iMA(NULL,PERIOD_H1,slowma,0,MODE_EMA,PRICE_CLOSE,1); double FastTrend = iMA(NULL,PERIOD_H1,fastma,0,MODE_EMA,PRICE_CLOSE,1); if((MathAbs(FastTrend-SlowTrend)gt; RangePoint * Point)){RangingS = 2; } else {RangingS = 1; } if((TFTime!= iTime(Symbol(),PERIOD_M15,1))(RangingS == 1)){RangePreFetch(); MaxpipfromEMA = MaxpipfromEMAM;測距= 1; TFTime = ITIME(符號(),PERIOD_M15,1); } if((TFTime!= iTime(Symbol(),PERIOD_H1,1))(RangingS == 2)){TrendPreFetch(); MaxpipfromEMA = MaxpipfromEMAH;測距= 0; TFTime = ITIME(符號(),PERIOD_H1,1); }

ALEXCHANDLO85
12-07-2021 17:03, 05:03 PM
即使進行了優化,iCustom功能也會降低您的EA速度。也就是說,我有一些建議:在最後一刻計算這些內容。不要讓那些if語句調用RangePreFetch和TrendPreFetch,而是讓它們將句點變量設置為PERIOD_H1或PERIOD_M15。然後根據需要使用您的期間變量到獨立時間幀來計算內容。而不是計算每個刻度的每個印象,你可能會發現你只計算大多數刻度的兩個左右的印記。優化內飾。在定制的室內裝飾中通常有很多優化空間。如果您有源,請給它一次性。