19评论

0收藏

这个EA测试没问题,为什么不能实际交易?不会开仓

 

avatar 生活鸭梨 | 4875 人阅读 | 19 人评论 | 2012-11-30

  1. extern int Pips = 10;
  2. extern double Lots = 0.1;
  3. int g_file_88;
  4. bool gi_92 = TRUE;
  5. bool gi_96 = FALSE ;
  6. int gi_100 = 999999;
  7. int gi_104 = 0;
  8. int gi_108;
  9. int gi_112 = 0;
  10. int gi_116 = 0;
  11. double gd_120;
  12. int GetTime(int ai_0) {
  13. FileSeek(g_file_88, ai_0 + 148, SEEK_SET);
  14. int li_4 = FileReadInteger(g_file_88);
  15. return (li_4);
  16. }
  17. int FindTimePlace(int ai_0) {
  18. int li_4;
  19. int li_8;
  20. int li_12 = 0;
  21. int li_16 = FileSize(g_file_88) - 148 - 44;
  22. int li_20 = GetTime(li_12);
  23. int li_24 = GetTime(li_16);
  24. while (li_20 < ai_0 && ai_0 < li_24) {
  25. li_8 = (li_12 + li_16) / 2;
  26. li_8 -= li_8 % 44;
  27. if (li_8 == li_12) break;
  28. li_4 = GetTime(li_8);
  29. if (ai_0 >= li_4) {
  30. li_12 = li_8;
  31. li_20 = GetTime(li_12);
  32. } else {
  33. li_16 = li_8;
  34. li_24 = GetTime(li_16);
  35. }
  36. }
  37. if (ai_0 <= li_24) {
  38. FileSeek(g_file_88, li_12 + 148, SEEK_SET);
  39. return (1);
  40. }
  41. return (0);
  42. }
  43. void init() {
  44. g_file_88 = FileOpenHistory(Symbol() + Period() + ".hst", FILE_BIN | FILE_READ);
  45. if (g_file_88 > 0) gi_92 = TRUE;
  46. else {
  47. gi_92 = FALSE;
  48. return;
  49. }
  50. gi_92 = FindTimePlace(Time[0]);
  51. if (!gi_92) FileClose(g_file_88);
  52. }
  53. void deinit() {
  54. if (gi_92) FileClose(g_file_88);
  55. }
  56. int GetPrices(int &ai_0, int &ai_4, int &ai_8) {
  57. ai_0 = FileReadInteger(g_file_88);
  58. FileSeek(g_file_88, 8, SEEK_CUR);
  59. ai_4 = FileReadDouble(g_file_88) / Point + 0.1;
  60. ai_8 = FileReadDouble(g_file_88) / Point + 0.1;
  61. FileSeek(g_file_88, 16, SEEK_CUR);
  62. if (FileTell(g_file_88) + 44 <= FileSize(g_file_88)) return (1);
  63. return (0);
  64. }
  65. int GetTimeTrade(double &ad_0) {
  66. int li_8;
  67. int li_12;
  68. int li_16;
  69. while (true) {
  70. if (!GetPrices(li_8, li_12, li_16)) return (-1);
  71. if (gi_96) {
  72. if (li_16 > gi_104) {
  73. gi_104 = li_16;
  74. gi_108 = li_8;
  75. continue;
  76. }
  77. if (gi_104 - li_12 < Pips) continue;
  78. gi_96 = FALSE;
  79. gi_100 = li_12;
  80. ad_0 = gi_104 * Point;
  81. } else {
  82. if (li_12 < gi_100) {
  83. gi_100 = li_12;
  84. gi_108 = li_8;
  85. continue;
  86. }
  87. if (li_16 - gi_100 < Pips) continue;
  88. gi_96 = TRUE;
  89. gi_104 = li_16;
  90. ad_0 = gi_100 * Point;
  91. }
  92. break;
  93. }
  94. int li_ret_20 = gi_108;
  95. gi_108 = li_8;
  96. return (li_ret_20);
  97. }
  98. void CloseOrder(int a_ticket_0) {
  99. OrderSelect(a_ticket_0, SELECT_BY_TICKET);
  100. if (OrderType() == OP_BUY) {
  101. OrderClose(a_ticket_0, OrderLots(), Bid, 5);
  102. return;
  103. }
  104. OrderClose(a_ticket_0, OrderLots(), Ask, 5);
  105. }
  106. int ReverseOrder(int a_ticket_0) {
  107. if (a_ticket_0 == 0) a_ticket_0 = OrderSend(Symbol(), OP_BUY, Lots, Ask, 16, 0, 0);
  108. else {
  109. OrderSelect(a_ticket_0, SELECT_BY_TICKET);
  110. if (OrderType() == OP_BUY) {
  111. OrderClose(a_ticket_0, OrderLots(), Bid, 0);
  112. a_ticket_0 = OrderSend(Symbol(), OP_SELL, Lots, Bid, 16, 0, 0);
  113. } else {
  114. OrderClose(a_ticket_0, OrderLots(), Ask, 0);
  115. a_ticket_0 = OrderSend(Symbol(), OP_BUY, Lots, Ask, 16, 0, 0);
  116. }
  117. }
  118. return (a_ticket_0);
  119. }
  120. void System() {
  121. if (gi_116 == 0) gi_116 = GetTimeTrade(gd_120);
  122. else
  123. if (gi_116 < 0) return;
  124. if (Time[0] == gi_116) {
  125. if (NormalizeDouble(Bid - gd_120, Digits) == 0.0) {
  126. gi_116 = GetTimeTrade(gd_120);
  127. if (gi_116 < 0) {
  128. CloseOrder(gi_112);
  129. return;
  130. }
  131. gi_112 = ReverseOrder(gi_112);
  132. }
  133. }
  134. }
  135. void start() {
  136. if (gi_92) {
  137. System();
  138. return;
  139. }
  140. }

复制代码

金币

参与人数 1金币 +4 收起 理由
xwfboy + 4

查看全部打赏

""
还没有人打赏,支持一下

评论|共 19 个

掘金帮小飞

发表于 2012-11-30 16:02:14 | 显示全部楼层

谢谢分享了!  

夏天的风

发表于 2012-11-30 16:02:14 | 显示全部楼层

加油啊!!!!顶哦!!!!!  

fanhongli123

发表于 2012-11-30 16:02:14 | 显示全部楼层

帮你顶,人还是厚道点好  

qqboy

发表于 2012-11-30 16:02:14 | 显示全部楼层

鉴定完毕.!  

相亲

发表于 2012-11-30 16:02:14 | 显示全部楼层

加油站加油  

tianxiahui578

发表于 2012-11-30 16:02:14 | 显示全部楼层

资金量设置的是10000美元啊,  

seegoto

发表于 2013-1-6 12:54:13 | 显示全部楼层

做人要厚道

zhmickey

发表于 2013-1-16 09:14:43 | 显示全部楼层

顶贴一个~~

nhh123456

发表于 2013-1-16 14:09:23 | 显示全部楼层

谢谢分享了!  

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

EA之家评论守则