Hei, saya ada soalan untuk beberapa pemrogram metatrader yang sangat baik. Dalam EA saya, saya beralih antara tempoh masa bergantung kepada fungsi. Sekiranya EA menentukan saya harus menggunakan tempoh masa 15 minit, maka panggilan pada RangePrefetch () betul selepas mula (). Sekiranya saya perlu menggunakan carta 1 jam, maka EA menyeru TrendPrefetch () sebaik sahaja mula (). Kedua-dua RangePrefetch () dan TrendPrefetch () adalah sama persis kecuali tempoh, dan ia ditakrifkan dan selepas init ().
Masalahnya adalah kerana peralihan ini berulang-ulang antara masa, memerlukan lebih lama untuk mengujinya dan mengoptimumkannya. Oleh itu, saya tertanya-tanya sama ada terdapat beberapa cara untuk menyusun semula kod atau coding itu cara yang lebih cekap supaya semua berjalan lebih cepat. terima kasih banyak-banyak.
Kod yang disisipkan extern dua JumpWidth_Percen = 0.25; Trend senar, Beli, Menjual, 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, Lebar1, Lebar2, Lebar3, Lebar4, Lebar5, Lebar6, LebarW1, LebarW2, WidthW3, WidthW4, WidthW5, WidthW6, FastTrend, SlowTrend; int Trendd, MaxpipfromEMA, Ranging, RangingS, TFTime; tidak sah TrendPreFetch () {Purata = 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 () {Purata = 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, terbuka, Spike, SpikeW, Buyjump, Selljump, BuyjumpR, SelljumpR, Tiket, Cnt, Boleh; 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); jika ((MathAbs (FastTrend-SlowTrend) gt; RangePoint * Point)) {RangingS = 2; } else {RangingS = 1; } jika ((TFTime! = iTime (Symbol (), PERIOD_M15,1)) (RangingS == 1)) {RangePreFetch (); MaxpipfromEMA = MaxpipfromEMAM; Ranging = 1; TFTime = iTime (Simbol (), PERIOD_M15,1); } jika ((TFTime! = iTime (Symbol (), PERIOD_H1,1)) (RangingS == 2)) {TrendPreFetch (); MaxpipfromEMA = MaxpipfromEMAH; Ranging = 0; TFTime = iTime (Simbol (), PERIOD_H1,1); }