retesere20

-----recycler-----

Jul 24th, 2018
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2. // ############################################## RealTime-Test orders ################################################
  3. #region Real-Time Test
  4.  
  5. // vars:
  6. // RTTest(false),
  7. // intrabarpersist LastDir(0),
  8. // Test_LongEntry(false),
  9. // Test_ShortReverse(false),
  10. // Test_ShortReverseLimit(false),
  11. // Test_ShortEntry(false),
  12. // Test_LongReverse(false),
  13.  
  14. // Test_LongExit1(false),
  15. // Test_LongExit1Pct(100),
  16. // Test_LongExit2(false),
  17. // Test_LongExit2Pct(60),
  18. // Test_LongExit3(false),
  19. // Test_LongExit3Pct(100),
  20.  
  21. // Test_ShortExit1(false),
  22. // Test_ShortExit1Pct(100),
  23. // Test_ShortExit2(false),
  24. // Test_ShortExit2Pct(60),
  25. // Test_ShortExit3(false),
  26. // Test_ShortExit3Pct(100),
  27.  
  28. // RTExitShares(0),
  29. // intrabarpersist PrevRT(false),
  30. // intrabarpersist HistPositionCleared(false),
  31. // intrabarpersist Test_LongEntryPlaced(false), DateTime Test_LongEntryDT(null),
  32. // intrabarpersist Test_ShortEntryPlaced(false), DateTime Test_ShortEntryDT(null),
  33.  
  34. // intrabarpersist Test_ShortReversePlaced(false),
  35. // intrabarpersist Test_LongReversePlaced(false),
  36.  
  37. // intrabarpersist Test_LongExit1Placed(false), DateTime Test_LongExit1DT(null),
  38. // intrabarpersist Test_LongExit2Placed(false), DateTime Test_LongExit2DT(null),
  39. // intrabarpersist Test_LongExit3Placed(false),
  40.  
  41. // intrabarpersist Test_ShortExit1Placed(false), DateTime Test_ShortExit1DT(null),
  42. // intrabarpersist Test_ShortExit2Placed(false), DateTime Test_ShortExit2DT(null),
  43. // intrabarpersist Test_ShortExit3Placed(false),
  44.  
  45. // intrabarpersist LimitSSOn(false);
  46.  
  47. if RTTest and RT then begin
  48.  
  49. if PrevRT = false then begin
  50.  
  51. if MarketPosition=1 then
  52. order_Exit("RT Exit LX", 0, 0)
  53. else if MarketPosition=-1 then
  54. order_Exit("RT Exit SX", 0, 0);
  55. end;
  56.  
  57. if MarketPosition=0 then
  58. HistPositionCleared = true;
  59.  
  60. if Test_LongEntry and Test_LongEntryPlaced = false and
  61. (Test_ShortEntry = false or (Test_ShortExit1Placed and SecondsElapsed(Test_ShortExit1DT) >= 10)) and
  62. MarketPosition=0
  63. then begin
  64.  
  65. if LONG_allowed then begin
  66. order_Exit("RT Test LE", 0, 0);
  67. LastDir = 1;
  68. Test_LongEntryPlaced = true;
  69. Test_LongEntryDT = DateTime.Now;
  70. end;
  71. end;
  72.  
  73. if Test_ShortEntry and Test_ShortEntryPlaced = false and
  74. //(Test_LongEntry = false or Test_LongExit1Placed) and
  75. MarketPosition=0
  76. then begin
  77.  
  78. if SHORT_allowed then begin
  79. order_Exit("RT Test SE", 0, 0);
  80. LastDir = -1;
  81. Test_ShortEntryPlaced = true;
  82. Test_ShortEntryDT = DateTime.Now;
  83. end;
  84. end;
  85.  
  86. if LastDir = 1 and Test_ShortReverse and Test_ShortReversePlaced = false and
  87. (Test_LongEntryPlaced or Test_LongReversePlaced) and MarketPosition=1 and
  88. SecondsElapsed(Test_LongEntryDT) >= 10
  89. then begin
  90.  
  91. if SHORT_allowed then begin
  92. if Test_ShortReverseLimit then
  93. LimitSSOn = true
  94. else
  95. order_Exit("RT Reverse SE", 0, 0);
  96.  
  97. LastDir = -1;
  98. Test_ShortReversePlaced = true;
  99. Test_ShortEntryDT = DateTime.Now;
  100.  
  101. Test_LongReversePlaced = false;
  102. end;
  103. end
  104.  
  105. else if LastDir = -1 and Test_LongReverse and Test_LongReversePlaced = false and
  106. (Test_ShortEntryPlaced or Test_ShortReversePlaced) and MarketPosition=-1 and
  107. SecondsElapsed(Test_ShortEntryDT) >= 10
  108. then begin
  109.  
  110. if LONG_allowed then begin
  111. order_Exit("RT Reverse LE", 0, 0);
  112. LastDir = 1;
  113. Test_LongReversePlaced = true;
  114. Test_LongEntryDT = DateTime.Now;
  115. Test_ShortReversePlaced = false;
  116. end;
  117. end;
  118.  
  119. if LimitSSOn then
  120. if SHORT_allowed then begin
  121. order_Exit("RT Reverse Lmt SE", 0, close + 2 * tick);
  122. end;
  123.  
  124. if Test_LongExit1 and Test_LongExit1Placed = false and
  125. Test_LongEntryPlaced and MarketPosition=1 and
  126. SecondsElapsed(Test_LongEntryDT) >= 10
  127. then begin
  128.  
  129. if LONG_allowed then begin
  130. RTExitShares = IntPortion(currentshares * Test_LongExit1Pct * 0.01);
  131. order_Exit("RT Exit1 LX", RTExitShares, 0);
  132. order_Exit("RT Test LE2", 0, 0);
  133. Test_LongExit1Placed = true;
  134. Test_LongExit1DT = DateTime.Now;
  135. end;
  136. end;
  137.  
  138. if Test_LongExit2 and Test_LongExit2Placed = false and
  139. Test_LongExit1Placed and MarketPosition=1 and
  140. SecondsElapsed(Test_LongExit1DT) >= 10
  141. then begin
  142.  
  143. RTExitShares = IntPortion(currentshares * Test_LongExit2Pct * 0.01);
  144. order_Exit("RT Exit2 LX", RTExitShares, 0);
  145. Test_LongExit2Placed = true;
  146. Test_LongExit2DT = DateTime.Now;
  147. end;
  148.  
  149. if Test_LongExit3 and Test_LongExit3Placed = false and
  150. Test_LongExit2Placed and MarketPosition=1 and
  151. SecondsElapsed(Test_LongExit2DT) >= 10
  152. then begin
  153.  
  154. RTExitShares = IntPortion(currentshares * Test_LongExit3Pct * 0.01);
  155. order_Exit("RT Exit3 LX", RTExitShares, 0);
  156. Test_LongExit3Placed = true;
  157. end;
  158.  
  159. if Test_ShortExit1 and Test_ShortExit1Placed = false and
  160. Test_ShortEntryPlaced and MarketPosition=-1 and
  161. SecondsElapsed(Test_ShortEntryDT) >= 10
  162. then begin
  163.  
  164. if SHORT_allowed then begin
  165. RTExitShares = IntPortion(currentshares * Test_ShortExit1Pct * 0.01);
  166. order_Exit("RT Exit1 SX", RTExitShares, 0);
  167. order_Exit("RT Test SE2", 0, 0);
  168. Test_ShortExit1Placed = true;
  169. Test_ShortExit1DT = DateTime.Now;
  170. end;
  171. end;
  172.  
  173. if Test_ShortExit2 and Test_ShortExit2Placed = false and
  174. Test_ShortExit1Placed and MarketPosition=-1 and
  175. SecondsElapsed(Test_ShortExit1DT) >= 10
  176. then begin
  177.  
  178. RTExitShares = IntPortion(currentshares * Test_ShortExit2Pct * 0.01);
  179. order_Exit("RT Exit2 SX", RTExitShares, 0);
  180. Test_ShortExit2Placed = true;
  181. Test_ShortExit2DT = DateTime.Now;
  182. end;
  183.  
  184. if Test_ShortExit3 and Test_ShortExit3Placed = false and
  185. Test_ShortExit2Placed and MarketPosition=-1 and
  186. SecondsElapsed(Test_ShortExit2DT) >= 10
  187. then begin
  188.  
  189. RTExitShares = IntPortion(currentshares * Test_ShortExit3Pct * 0.01);
  190. order_Exit("RT Exit3 SX", RTExitShares, 0);
  191. Test_ShortExit3Placed = true;
  192. end;
  193. end;
  194.  
  195. #endregion
  196. }
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230. ========================== orders ========================================
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241. //
  242. else if (name= "RT Test LE2" ) then
  243. buy ( "RT Test LE2" ) next bar at market
  244. else if (name= "RT Test SE2" ) then
  245. sell short( "RT Test SE2" ) next bar at market
  246. else if (name= "RT Exit1 LX" ) then
  247. sell ( "RT Exit1 LX" ) sharesNum shares next bar at market
  248. else if (name= "RT Exit1 SX" ) then
  249. buy to cover("RT Exit1 SX" ) sharesNum shares next bar at market
  250. else if (name= "RT Exit2 LX" ) then
  251. sell ( "RT Exit2 LX" ) sharesNum shares next bar at market
  252. else if (name= "RT Exit2 SX" ) then
  253. buy to cover("RT Exit2 SX" ) sharesNum shares next bar at market
  254. else if (name= "RT Exit3 LX" ) then
  255. sell ( "RT Exit3 LX" ) sharesNum shares next bar at market
  256. else if (name= "RT Exit3 SX" ) then
  257. buy to cover("RT Exit3 SX" ) sharesNum shares next bar at market
  258. //
  259. else if (name= "RT Exit LX" ) then
  260. sell( "RT Exit LX" ) next bar at market
  261. else if (name= "RT Exit SX" ) then
  262. buy to cover("RT Exit SX" ) next bar at market
  263. else if (name= "LX Sess_End" ) then
  264. sell ( "LX Sess_End" ) this bar on close
  265. else if (name= "SX Sess_End" ) then
  266. buy to cover("SX Sess_End" ) this bar on close
  267. //
  268. else if (name= "LX Break" ) then
  269. sell ( "LX Break" ) this bar on close
  270. else if (name= "SX Break" ) then
  271. buy to cover("SX Break" ) this bar on close
  272. //
  273. else if (name= "RT Test LE" ) then
  274. buy ( "RT Test LE" ) next bar at market
  275. else if (name= "RT Test SE" ) then
  276. sell short( "RT Test SE" ) next bar at market
  277. else if (name= "RT Reverse SE" ) then
  278. sell short( "RT Reverse SE" ) next bar at market
  279. else if (name= "RT Reverse LE" ) then
  280. buy ( "RT Reverse LE" ) next bar at market
  281. else if (name= "RT Reverse Lmt SE") then
  282. sell short( "RT Reverse Lmt SE") next bar at price limit
RAW Paste Data