13评论

0收藏

求牛版高手帮忙解决下EA编程难题弄了4天4夜了,帮下忙谢谢

 

avatar 淘客 | 5296 人阅读 | 13 人评论 | 2013-09-09

我连弄了4天4夜,怎么都弄不出来了,昨天晚上又看了一晚,有点崩溃了;
我学习编程都快15天了,还没出什么东西,希望等下发的代码能有高手帮忙解决下;
我的EA策略是:
       当 前根15分钟K线为阳线时,在本根15分钟K线大于等于前根K线收盘价之上2个点处买多进场;
       当 前根15分钟K线为阴线时,在本根15分钟K线小于等于前根K线收盘价之下2个点处买多进场;
      止损为固定加移动止损,移动止赢,代码里面有了;
      开仓按波动百分比限制开仓,这波动限制我一直想用时间来替换但弄了半天都不会用时间弄,如果
      高手能帮我设置下时间为北京时间下午15点到17点和20点到23点这2个时间段的开仓交易感激不尽;
下面为我弄的代码有点多有点乱,我都弄糊涂了,再加上这几天太兴奋弄这个4天没睡觉了,我要补下觉
当我睡起来的时候能看到我想要的答案,麻烦各位大大了
  1. #property copyright "yuanzhong 2013, MetaQuotes Software Corp."
  2. #property link "http://www.metaquotes.net"
  3. #property show_inputs
  4. //#包括 <stdlib.mqh>
  5. #import "stdlib.ex4"
  6. string ErrorDescription(int a0);

  7. #import

  8. extern string Configuration = "==== 配置====";
  9. extern int Magic = 0;
  10. extern string OrderCmt = ""; //字符串顺序
  11. extern string Suffix = ""; //字符串的后缀
  12. extern bool NDDmode = FALSE; //模式
  13. extern bool Show_Debug = FALSE; //显示调试
  14. extern bool Verbose = FALSE; //版本玻璃色
  15. extern string TradingSettings = "==== 贸易设置 ====";
  16. extern bool TradeALLCurrencyPairs = FALSE; //贸易所有货币对
  17. extern double MaxSpread = 20.0; //最大滑点
  18. extern double TakeProfit = 7.0; //利润
  19. extern double StopLoss = 30.0; //止损
  20. extern double TrailingStart = 0.0; //拖曳开始
  21. extern double Commission = 7.0; //佣金
  22. extern bool UseDynamicVolatilityLimit = TRUE; //波动限制
  23. extern double VolatilityMultiplier = 125.0; //
  24. extern double VolatilityLimit = 180.0; //波动限制
  25. extern bool UseVolatilityPercentage = TRUE; //波动百分比
  26. extern double VolatilityPercentageLimit = 60.0; //波动百分比限制
  27. extern double Deviation = 1.5; //偏差
  28. extern int OrderExpireSeconds = 900; //订单到期秒
  29. extern string Money_Management = "==== 资金管理 ====";
  30. extern double MinLots = 0.01; //最小手数
  31. extern double MaxLots = 1000.0; //最大手数
  32. extern double Risk = 2.0; //风险值
  33. extern string Screen_Shooter = "==== 屏幕投影 ====";
  34. extern bool TakeShots = FALSE; //屏幕投影
  35. extern int DelayTicks = 1; //延迟
  36. extern int ShotsPerBar = 1; //项目分拦
  37. string gsa_272[26] = {"EURUSD", "USDJPY", "GBPUSD", "USDCHF", "USDCAD", "AUDUSD", "NZDUSD", "EURJPY", "GBPJPY", "CHFJPY", "CADJPY", "AUDJPY", "NZDJPY", "EURCHF", "EURGBP", "EURCAD", "EURAUD",
  38. "EURNZD", "GBPCHF", "GBPAUD", "GBPCAD", "GBPNZD", "AUDCHF", "AUDCAD", "AUDNZD", "NZDCHF",
  39. "NZDCAD", "CADCHF"};
  40. string gsa_276[];
  41. bool gi_unused_284 = FALSE;
  42. bool gi_288 = TRUE;
  43. bool gi_292 = FALSE;
  44. int gi_300 = 0;
  45. int g_digits_304 = 0;
  46. int g_slippage_308 = 3;
  47. int gia_312[30];
  48. int gi_316 = 0;
  49. int g_time_320 = 0;
  50. int g_count_324 = 0;
  51. int gi_328 = 0;
  52. int gi_332 = 0;
  53. int gi_336 = 0;
  54. double g_pips_340 = 0.0;
  55. double gd_unused_348 = 0.0;
  56. double g_lots_356 = 0.1;
  57. double gd_unused_364 = 0.4;
  58. double gd_372 = 1.0;
  59. double g_pips_380 = 5.0;
  60. double g_pips_388 = 10.0;
  61. double g_pips_396 = 20.0;
  62. double gda_404[30];
  63. double gda_408[30];
  64. double gda_412[30];
  65. double gd_416;
  66. double gd_424;
  67. int gi_440;
  68. int gi_444 = -1;
  69. int gi_448 = 3000000;
  70. int gi_452 = 0;

  71. int init() {
  72. VolatilityPercentageLimit = VolatilityPercentageLimit / 100.0 + 1.0;
  73. VolatilityMultiplier /= 10.0;
  74. ArrayInitialize(gda_412, 0);
  75. VolatilityLimit *= Point;
  76. Commission = f0_12(Commission * Point);
  77. g_digits_304 = Digits;
  78. int li_0 = MathMax(MarketInfo(Symbol(), MODE_FREEZELEVEL), MarketInfo(Symbol(), MODE_STOPLEVEL));
  79. if (TakeProfit < li_0) TakeProfit = li_0;
  80. if (StopLoss < li_0) StopLoss = li_0;
  81. if (gi_300 < li_0) gi_300 = li_0;
  82. if (MathMod(Digits, 2) == 0.0) g_slippage_308 = 0;
  83. else gi_316 = -1;
  84. if (MaxLots > MarketInfo(Symbol(), MODE_MAXLOT)) MaxLots = MarketInfo(Symbol(), MODE_MAXLOT);
  85. if (MinLots < MarketInfo(Symbol(), MODE_MINLOT)) MinLots = MarketInfo(Symbol(), MODE_MINLOT);
  86. if (TradeALLCurrencyPairs == TRUE) f0_6();
  87. if (Magic < 0) f0_13();
  88. start();
  89. return (0);
  90. }

  91. int deinit() {
  92. return (0);
  93. }

  94. int start() {
  95. if (g_digits_304 == 0) return (init());
  96. f0_1(gda_404, gda_408, gia_312, gd_372);
  97. f0_8();
  98. return (0);
  99. }

  100. void f0_8() {
  101. string ls_0;
  102. string symbol_8;
  103. bool bool_16;
  104. bool li_20;
  105. int li_unused_24;
  106. bool li_28;
  107. int li_32;
  108. int li_unused_36;
  109. int ticket_40;
  110. int datetime_44;
  111. int li_48;
  112. int li_52;
  113. int li_56;
  114. int pos_60;
  115. int li_68;
  116. int index_72;
  117. int count_76;
  118. double price_84;
  119. double price_92;
  120. double ld_100;
  121. double ld_108;
  122. double ld_116;
  123. double ld_124;
  124. double order_stoploss_140;
  125. double order_takeprofit_148;
  126. double ld_156;
  127. double ld_180;
  128. double ld_188;
  129. double ld_228;
  130. double ld_236;
  131. double ld_244;
  132. double ld_252;
  133. double ld_260;
  134. double ld_268;
  135. double ld_276;
  136. double ld_284;
  137. double ld_292;
  138. if (g_time_320 < Time[0]) {
  139. g_time_320 = Time[0];
  140. g_count_324 = 0;
  141. } else g_count_324++;
  142. if (TradeALLCurrencyPairs == FALSE) {
  143. gi_336 = 1;
  144. symbol_8 = Symbol();
  145. }
  146. for (int count_80 = 0; count_80 != gi_336; count_80++) {
  147. symbol_8 = gsa_276[index_72];
  148. iBars_164 = iBars(symbol_8, PERIOD_M15,PRICE_CLOSE[1]);
  149. iBars_172 = iBars(symbol_8, PERIOD_M15,PRICE_OPEN[1]);
  150. if(iBars_164>iBars_172 && Ask>iBars_164) ... //开BUY单
  151. if(iBars_164<iBars_172 && Bid<iBars_164) ... //开SELL单
  152. ld_188=iBars_164>iBars_172;
  153. ld_180=iBars_164<iBars_172;
  154. li_28 = Bid;
  155. li_unused_36 = 0;
  156. if (li_28 == 1) {
  157. li_unused_36 = 1;
  158. gd_416 = MathMax(ld_188);
  159. gd_424 = MathMin(ld_180);
  160. }
  161. }
  162. ld_236 = MathMax(MarketInfo(symbol_8, MODE_FREEZELEVEL), MarketInfo(symbol_8, MODE_STOPLEVEL)) * Point;
  163. ld_244 = Ask - Bid;
  164. if (ld_236 > 1.0 * Point) {
  165. li_20 = FALSE;
  166. ld_108 = MaxSpread * Point;
  167. ld_252 = g_pips_388 * Point;
  168. ld_116 = g_pips_380 * Point;
  169. } else {
  170. li_20 = TRUE;
  171. ld_108 = g_pips_396 * Point;
  172. ld_252 = g_pips_340 * Point;
  173. ld_116 = TrailingStart * Point;
  174. }
  175. ld_108 = MathMax(ld_108, ld_236);
  176. if (li_20) ld_252 = MathMax(ld_252, ld_236);
  177. ArrayCopy(gda_412, gda_412, 0, 1, 29);
  178. gda_412[29] = ld_244;
  179. if (gi_328 < 30) gi_328++;
  180. ld_260 = 0;
  181. pos_60 = 29;
  182. for (int count_64 = 0; count_64 < gi_328; count_64++) {
  183. ld_260 += gda_412[pos_60];
  184. pos_60--;
  185. }
  186. ld_268 = ld_260 / gi_328;
  187. ld_276 = f0_12(Ask + Commission);
  188. ld_284 = f0_12(Bid - Commission);
  189. ld_292 = ld_268 + Commission;
  190. if (UseDynamicVolatilityLimit == TRUE) VolatilityLimit = ld_292 * VolatilityMultiplier;
  191. li_68 = 0;
  192. if (ld_228 && VolatilityLimit && gd_424 && gd_416) {
  193. if (ld_228 > VolatilityLimit) {
  194. ld_100 = ld_228 / VolatilityLimit;
  195. if (UseVolatilityPercentage == FALSE || (UseVolatilityPercentage == TRUE && ld_100 > VolatilityPercentageLimit)) {
  196. if (Bid < gd_424) li_68 = -1;
  197. else
  198. if (Bid > gd_416) li_68 = 1;
  199. }
  200. } else ld_100 = 0;
  201. }
  202. ld_124 = MathMax(ld_236, ld_124);
  203. if (Bid == 0.0 || MarketInfo(symbol_8, MODE_LOTSIZE) == 0.0) ld_124 = 0;
  204. datetime_44 = TimeCurrent() + OrderExpireSeconds;
  205. if (MarketInfo(symbol_8, MODE_LOTSTEP) == 0.0) li_48 = 5;
  206. else li_48 = f0_3(0.1, MarketInfo(symbol_8, MODE_LOTSTEP));
  207. if (Risk < 0.001 || Risk > 100.0) {
  208. Comment("ERROR -- Invalid Risk Value.");
  209. return;
  210. }
  211. if (AccountBalance() <= 0.0) {
  212. Comment("ERROR -- Account Balance is " + DoubleToStr(MathRound(AccountBalance()), 0));
  213. return;
  214. }
  215. g_lots_356 = f0_10(symbol_8);
  216. index_72 = 0;
  217. count_76 = 0;
  218. for (pos_60 = 0; pos_60 < OrdersTotal(); pos_60++) {
  219. OrderSelect(pos_60, SELECT_BY_POS, MODE_TRADES);
  220. if (OrderMagicNumber() == Magic && OrderCloseTime() == 0) {
  221. if (OrderSymbol() != symbol_8) {
  222. count_76++;
  223. continue;
  224. }
  225. switch (OrderType()) {
  226. case OP_BUY:
  227. if (gi_288) {
  228. order_stoploss_140 = OrderStopLoss();
  229. order_takeprofit_148 = OrderTakeProfit();
  230. if ((order_takeprofit_148 < f0_12(ld_276 + ld_108) && ld_276 + ld_108 - order_takeprofit_148 > ld_116)) {
  231. order_stoploss_140 = f0_12(Bid - ld_108);
  232. order_takeprofit_148 = f0_12(ld_276 + ld_108);
  233. gi_332 = GetTickCount();
  234. bool_16 = OrderModify(OrderTicket(), 0, order_stoploss_140, order_takeprofit_148, datetime_44, Lime);
  235. gi_332 = GetTickCount() - gi_332;
  236. if (bool_16 > FALSE && TakeShots && (!IsTesting()) && (!gi_292)) f0_7();
  237. }
  238. }
  239. index_72++;
  240. continue;
  241. break;
  242. case OP_SELL:
  243. if (gi_288) {
  244. order_stoploss_140 = OrderStopLoss();
  245. order_takeprofit_148 = OrderTakeProfit();
  246. if ((order_takeprofit_148 > f0_12(ld_284 - ld_108) && order_takeprofit_148 - ld_284 + ld_108 > ld_116)) {
  247. order_stoploss_140 = f0_12(Ask + ld_108);
  248. order_takeprofit_148 = f0_12(ld_284 - ld_108);
  249. gi_332 = GetTickCount();
  250. bool_16 = OrderModify(OrderTicket(), 0, order_stoploss_140, order_takeprofit_148, datetime_44, Orange);
  251. gi_332 = GetTickCount() - gi_332;
  252. if (bool_16 > FALSE && TakeShots && (!IsTesting()) && (!gi_292)) f0_7();
  253. }
  254. }
  255. index_72++;
  256. continue;
  257. break;
  258. case OP_BUYSTOP:
  259. if (!li_28) {
  260. ld_156 = OrderTakeProfit() - OrderOpenPrice() - Commission;
  261. if ((f0_12(Ask + ld_252) < OrderOpenPrice() && OrderOpenPrice() - Ask - ld_252 > ld_116)) {
  262. gi_332 = GetTickCount();
  263. bool_16 = OrderModify(OrderTicket(), f0_12(Ask + ld_252), f0_12(Bid + ld_252 - ld_156), f0_12(ld_276 + ld_252 + ld_156), 0, Lime);
  264. gi_332 = GetTickCount() - gi_332;
  265. }
  266. index_72++;
  267. continue;
  268. }
  269. OrderDelete(OrderTicket());
  270. continue;
  271. break;
  272. case OP_SELLSTOP: break;
  273. }
  274. if (li_28) {
  275. ld_156 = OrderOpenPrice() - OrderTakeProfit() - Commission;
  276. if ((f0_12(Bid - ld_252) > OrderOpenPrice() && Bid - ld_252 - OrderOpenPrice() > ld_116)) {
  277. gi_332 = GetTickCount();
  278. bool_16 = OrderModify(OrderTicket(), f0_12(Bid - ld_252), f0_12(Ask - ld_252 + ld_156), f0_12(ld_284 - ld_252 - ld_156), 0, Orange);
  279. gi_332 = GetTickCount() - gi_332;
  280. }
  281. index_72++;
  282. continue;
  283. }
  284. OrderDelete(OrderTicket());
  285. }
  286. }
  287. li_unused_24 = 0;
  288. if (gi_316 >= 0 || gi_316 == -2) {
  289. li_52 = NormalizeDouble(Bid / Point, 0);
  290. li_56 = NormalizeDouble(Ask / Point, 0);
  291. if (li_52 % 10 != 0 || li_56 % 10 != 0) gi_316 = -1;
  292. else {
  293. if (gi_316 >= 0 && gi_316 < 10) gi_316++;
  294. else gi_316 = -2;
  295. }
  296. }
  297. if (index_72 == 0 && li_68 != 0 && f0_12(ld_292) <= f0_12(MaxSpread * Point) && gi_316 == -1) {
  298. if (li_68 < 0) {
  299. gi_332 = GetTickCount();
  300. if (li_20) {
  301. price_84 = Ask + gi_300 * Point;
  302. if (NDDmode) {
  303. ticket_40 = OrderSend(symbol_8, OP_BUYSTOP, g_lots_356, price_84, g_slippage_308, 0, 0, OrderCmt, Magic, 0, Lime);
  304. if (OrderSelect(ticket_40, SELECT_BY_TICKET)) OrderModify(OrderTicket(), OrderOpenPrice(), price_84 - StopLoss * Point, price_84 + TakeProfit * Point, datetime_44, Lime);
  305. } else {
  306. ticket_40 = OrderSend(symbol_8, OP_BUYSTOP, g_lots_356, price_84, g_slippage_308, price_84 - StopLoss * Point, price_84 + TakeProfit * Point, OrderCmt, Magic, datetime_44,
  307. Lime);
  308. }
  309. if (ticket_40 < 0) {
  310. li_unused_24 = 1;
  311. Print("ERROR BUYSTOP : " + f0_4(Ask + ld_252) + " SL:" + f0_4(Bid + ld_252 - ld_124) + " TP:" + f0_4(ld_276 + ld_252 + ld_124));
  312. gi_332 = 0;
  313. } else {
  314. gi_332 = GetTickCount() - gi_332;
  315. PlaySound("news.wav");
  316. Print("BUYSTOP : " + f0_4(Ask + ld_252) + " SL:" + f0_4(Bid + ld_252 - ld_124) + " TP:" + f0_4(ld_276 + ld_252 + ld_124));
  317. }
  318. } else {
  319. if (Bid - ilow_172 > 0.0) {
  320. ticket_40 = OrderSend(symbol_8, OP_BUY, g_lots_356, Ask, g_slippage_308, 0, 0, OrderCmt, Magic, datetime_44, Lime);
  321. if (ticket_40 < 0) {
  322. li_unused_24 = 1;
  323. Print("ERROR BUY Ask:" + f0_4(Ask) + " SL:" + f0_4(Bid - ld_124) + " TP:" + f0_4(ld_276 + ld_124));
  324. gi_332 = 0;
  325. } else {
  326. bool_16 = OrderModify(ticket_40, 0, f0_12(Bid - ld_124), f0_12(ld_276 + ld_124), datetime_44, Lime);
  327. gi_332 = GetTickCount() - gi_332;
  328. PlaySound("news.wav");
  329. Print("BUY Ask:" + f0_4(Ask) + " SL:" + f0_4(Bid - ld_124) + " TP:" + f0_4(ld_276 + ld_124));
  330. }
  331. }
  332. }
  333. } else {
  334. if (li_68 > 0) {
  335. if (li_20) {
  336. price_92 = Bid - gi_300 * Point;
  337. gi_332 = GetTickCount();
  338. if (NDDmode) {
  339. ticket_40 = OrderSend(symbol_8, OP_SELLSTOP, g_lots_356, price_92, g_slippage_308, 0, 0, OrderCmt, Magic, 0, Orange);
  340. if (OrderSelect(ticket_40, SELECT_BY_TICKET)) OrderModify(OrderTicket(), OrderOpenPrice(), price_92 + StopLoss * Point, price_92 - TakeProfit * Point, datetime_44, Orange);
  341. } else {
  342. ticket_40 = OrderSend(symbol_8, OP_SELLSTOP, g_lots_356, price_92, g_slippage_308, price_92 + StopLoss * Point, price_92 - TakeProfit * Point, OrderCmt, Magic, datetime_44,
  343. Orange);
  344. }
  345. if (ticket_40 < 0) {
  346. li_unused_24 = 1;
  347. Print("ERROR SELLSTOP : " + f0_4(Bid - ld_252) + " SL:" + f0_4(Ask - ld_252 + ld_124) + " TP:" + f0_4(ld_284 - ld_252 - ld_124));
  348. gi_332 = 0;
  349. } else {
  350. gi_332 = GetTickCount() - gi_332;
  351. PlaySound("news.wav");
  352. Print("SELLSTOP : " + f0_4(Bid - ld_252) + " SL:" + f0_4(Ask - ld_252 + ld_124) + " TP:" + f0_4(ld_284 - ld_252 - ld_124));
  353. }
  354. } else {
  355. if (ihigh_164 - Bid < 0.0) {
  356. ticket_40 = OrderSend(symbol_8, OP_SELL, g_lots_356, Bid, g_slippage_308, 0, 0, OrderCmt, Magic, datetime_44, Orange);
  357. if (ticket_40 < 0) {
  358. li_unused_24 = 1;
  359. Print("ERROR SELL Bid:" + f0_4(Bid) + " SL:" + f0_4(Ask + ld_124) + " TP:" + f0_4(ld_284 - ld_124));
  360. gi_332 = 0;
  361. } else {
  362. bool_16 = OrderModify(ticket_40, 0, f0_12(Ask + ld_124), f0_12(ld_284 - ld_124), datetime_44, Orange);
  363. gi_332 = GetTickCount() - gi_332;
  364. PlaySound("news.wav");
  365. Print("SELL Bid:" + f0_4(Bid) + " SL:" + f0_4(Ask + ld_124) + " TP:" + f0_4(ld_284 - ld_124));
  366. }
  367. }
  368. }
  369. }
  370. }
  371. }
  372. if (gi_316 >= 0) Comment("Robot is initializing...");
  373. else {
  374. if (gi_316 == -2) Comment("ERROR -- Instrument " + symbol_8 + " prices should have " + g_digits_304 + " fraction digits on broker account");
  375. else {
  376. ls_0 = TimeToStr(TimeCurrent()) + " Tick: " + f0_9(g_count_324);
  377. if (Show_Debug || Verbose) {
  378. ls_0 = ls_0
  379. + "\n*** DEBUG MODE *** \nVolatility: " + f0_4(ld_228) + ", VolatilityLimit: " + f0_4(VolatilityLimit) + ", VolatilityPercentage: " + f0_4(ld_100);
  380. ls_0 = ls_0
  381. + "\nPriceDirection: " + StringSubstr("BUY NULLSELL", li_68 * 4 + 4, 4) + ", IBarsOpen[1]: " + f0_4(iBars_172) + ", IBarsClose[1]: " + f0_4(iBars_164);
  382. ls_0 = ls_0 + ", Expire: " + TimeToStr(datetime_44, TIME_MINUTES) + ", NnumOrders: " + index_72;
  383. ls_0 = ls_0
  384. + "\nTrailingLimit: " + f0_4(ld_252) + ", TrailingDist: " + f0_4(ld_108) + "; TrailingStart: " + f0_4(ld_116) + ", UseStopOrders: " + li_20;
  385. }
  386. ls_0 = ls_0
  387. + "\nBid: " + f0_4(Bid) + ", Ask: " + f0_4(Ask) + ", AvgSpread: " + f0_4(ld_268) + ", Commission: " + f0_4(Commission) + ", RealAvgSpread: " + f0_4(ld_292) + ", Lots: " + f0_11(g_lots_356,
  388. li_48) + ", Execution: " + gi_332 + " ms";
  389. if (f0_12(ld_292) > f0_12(MaxSpread * Point)) {
  390. ls_0 = ls_0
  391. + "\n"
  392. + "The current spread (" + f0_4(ld_292) + ") is higher than what has been set as MaxSpread (" + f0_4(MaxSpread * Point) + ") so no trading is allowed right now on this currency pair!";
  393. }
  394. Comment(ls_0);
  395. if (index_72 != 0 || li_68 != 0 || Verbose) f0_2(ls_0);
  396. }
  397. }
  398. }
  399. }

  400. void f0_1(double &ada_0[30], double &ada_4[30], int &aia_8[30], double a_pips_12) {
  401. if (aia_8[0] == 0 || MathAbs(Bid - ada_0[0]) >= a_pips_12 * Point) {
  402. for (int li_20 = 29; li_20 > 0; li_20--) {
  403. ada_0[li_20] = ada_0[li_20 - 1];
  404. ada_4[li_20] = ada_4[li_20 - 1];
  405. aia_8[li_20] = aia_8[li_20 - 1];
  406. }
  407. ada_0[0] = Bid;
  408. ada_4[0] = Ask;
  409. aia_8[0] = GetTickCount();
  410. }
  411. }

  412. string f0_4(double ad_0) {
  413. return (DoubleToStr(ad_0, g_digits_304));
  414. }

  415. string f0_11(double ad_0, int ai_8) {
  416. return (DoubleToStr(ad_0, ai_8));
  417. }

  418. double f0_12(double ad_0) {
  419. return (NormalizeDouble(ad_0, g_digits_304));
  420. }

  421. string f0_9(int ai_0) {
  422. if (ai_0 < 10) return ("00" + ai_0);
  423. if (ai_0 < 100) return ("0" + ai_0);
  424. return ("" + ai_0);
  425. }

  426. double f0_3(double ad_0, double ad_8) {
  427. return (MathLog(ad_8) / MathLog(ad_0));
  428. }

  429. void f0_2(string as_0) {
  430. int li_8;
  431. int li_12 = -1;
  432. while (li_12 < StringLen(as_0)) {
  433. li_8 = li_12 + 1;
  434. li_12 = StringFind(as_0,
  435. "\n", li_8);
  436. if (li_12 == -1) {
  437. Print(StringSubstr(as_0, li_8));
  438. return;
  439. }
  440. Print(StringSubstr(as_0, li_8, li_12 - li_8));
  441. }
  442. }

  443. void f0_6() {
  444. string ls_unused_0;
  445. string ls_8;
  446. double ask_28;
  447. gi_336 = 0;
  448. for (int index_16 = 0; index_16 != gi_336; index_16++) {
  449. ls_8 = gsa_272[index_16];
  450. ask_28 = MarketInfo(ls_8 + Suffix, MODE_ASK);
  451. if (ask_28 != 0.0) {
  452. gi_336++;
  453. ArrayResize(gsa_276, gi_336);
  454. gsa_276[gi_336 - 1] = ls_8;
  455. } else Print("The broker does not support ", ls_8);
  456. }
  457. }

  458. int f0_13() {
  459. string ls_0 = Symbol();
  460. int str_len_8 = StringLen(ls_0);
  461. int li_12 = 0;
  462. for (int li_16 = 0; li_16 < str_len_8 - 1; li_16++) li_12 += StringGetChar(ls_0, li_16);
  463. Magic = AccountNumber() + li_12;
  464. return (0);
  465. }

  466. void f0_7() {
  467. int li_0;
  468. if (ShotsPerBar > 0) li_0 = MathRound(60 * Period() / ShotsPerBar);
  469. else li_0 = 60 * Period();
  470. int li_4 = MathFloor((TimeCurrent() - Time[0]) / li_0);
  471. if (Time[0] != gi_440) {
  472. gi_440 = Time[0];
  473. gi_444 = DelayTicks;
  474. } else
  475. if (li_4 > gi_448) f0_0("i");
  476. gi_448 = li_4;
  477. if (gi_444 == 0) f0_0("");
  478. if (gi_444 >= 0) gi_444--;
  479. }

  480. string f0_5(int ai_0, int ai_4) {
  481. for (string dbl2str_8 = DoubleToStr(ai_0, 0); StringLen(dbl2str_8) < ai_4; dbl2str_8 = "0" + dbl2str_8) {
  482. }
  483. return (dbl2str_8);
  484. }

  485. void f0_0(string as_0 = "") {
  486. gi_452++;
  487. string ls_8 = "SnapShot" + Symbol() + Period() + "\" + Year() + "-" + f0_5(Month(), 2) + "-" + f0_5(Day(), 2) + " " + f0_5(Hour(), 2) + "_" + f0_5(Minute(), 2) + "_" + f0_5(Seconds(),
  488. 2) + " " + gi_452 + as_0 + ".gif";
  489. if (!WindowScreenShot(ls_8, 640, 480)) Print("ScreenShot error: ", ErrorDescription(GetLastError()));
  490. }

  491. double f0_10(string a_symbol_0) {
  492. double lotstep_8 = MarketInfo(a_symbol_0, MODE_LOTSTEP);
  493. double ld_ret_16 = AccountFreeMargin() * Risk / StopLoss / 100.0;
  494. ld_ret_16 = MathFloor(ld_ret_16 / lotstep_8) * lotstep_8;
  495. if (g_lots_356 > MaxLots) g_lots_356 = MaxLots;
  496. if (g_lots_356 < MinLots) g_lots_356 = MinLots;
  497. return (ld_ret_16);
  498. }
复制代码
""
还没有人打赏,支持一下

评论|共 13 个

淘客

发表于 2013-9-9 10:20:05 | 显示全部楼层

看我糊涂的,
当 前根15分钟K线为阴线时,在本根15分钟K线小于等于前根K线收盘价之下2个点处卖空进场;

爱太痛

发表于 2013-9-9 13:19:04 | 显示全部楼层

可惜,我不会

三毛的弟弟

发表于 2013-9-9 21:04:59 | 显示全部楼层

睁眼瞎,不懂[s:140][s:140][s:140][s:140][s:140]

latitude43

发表于 2013-9-10 22:31:00 | 显示全部楼层

用hour()函数

翱翔长空

发表于 2013-9-11 13:05:55 | 显示全部楼层

dk

竹乐居士

发表于 2013-9-25 13:15:17 | 显示全部楼层

好红红火火好红红火火红红火火好

外汇笔记

发表于 2013-9-27 14:25:55 | 显示全部楼层

你这个像是破解的其它EA,感觉乱哄哄的。其实你的策略相对简单,完全可以自己从头编一个。如果想限制开仓时间,只需在开仓前加个时间判断函数就可以了。
比如:
extern double GMT_Diff = 2.5; //如果服务器所在时区为GMT+2.5
datetime GMT_Time = (TimeCurrent() - (3600 * GMT_Diff)); //得到GMT时间的秒数
//转换GMT时间
int GMT_Year=TimeYear(GMT_time);
int GMT_Month=TimeMonth(GMT_time);
int GMT_Day=TimeDay(GMT_time);
int GMT_Hour=TimeHour(GMT_time);
int GMT_Minite=TimeMinute(GMT_Time);
int GMT_Seconds=TimeSeconds(GMT_Time);

然后再将北京时间转换成GMT时间,也就是只在GMT时间的几点到几点开单就可以了
有不懂的到www.eanotes.com找我。

李华

发表于 2014-11-14 03:02:40 | 显示全部楼层

nice!!!!!!!!!!!!

wzshyz

发表于 2014-11-15 03:02:55 | 显示全部楼层

看看怎么样

12下一页
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则