Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1.  
  2. {
  3. Strategy Details:
  4. Symbol: U1
  5. Market 2: U2
  6. Market 3: U3
  7. Start Date: 20150401
  8. Stop Date: 20191027
  9. Out of Sample: 50 %
  10. Fitness Function: PNLDD
  11. Profit Target On: No
  12. Profit Multiple: 0
  13. Stop Loss On: No
  14. Stop Loss Multiple: 0
  15. Highest High On: No
  16. Highest High Lookback: 0
  17. Lowest Low On: No
  18. Lowest Low Lookback: 0
  19. Max Time: 1
  20. Profitable Closes: 9999
  21. }
  22.  
  23. inputs:
  24. CombineSignals(0), // 0 = all, +1 = long, -1 = short
  25. Required4Entry(0),
  26. Required4Exit(-99999), // if signal count falls below this number it will exit
  27. PT_ON(0),
  28. SL_ON(0),
  29. TL_ON(0),
  30. HH_ON(0),
  31. LL_ON(0),
  32. Max_Time(1),
  33. Profitable_Closes(9999),
  34. ReadFiles(false), // set to true to read from file, false if all info is on open charts
  35. atr_length(20),
  36. hh_length(0),
  37. ll_length(0),
  38. pt_mult(0.00),
  39. sl_mult(0.00),
  40. tl_mult(0.00),
  41. delay(0)
  42. ;
  43.  
  44. vars:
  45. isIBOG(GetAppInfo(aiIntraBarOrder) = 1),
  46. intrabarpersist mp(0),
  47. intrabarpersist mpPrev(0),
  48. intrabarpersist isClose(true),
  49. intrabarpersist isOpen(false),
  50. atr(0),
  51. hh(0),
  52. ll(0),
  53. prof_x(0),
  54. PT(0),
  55. SL(0),
  56. TL(0),
  57. PS(0)
  58. ;
  59.  
  60. isOpen = (isClose = true);
  61. isClose = (BarStatus(1) <> 1);
  62.  
  63. if isClose then begin
  64. hh = Highest(High, hh_length);
  65. ll = Lowest(Low, ll_length);
  66. atr = AvgTrueRange(atr_length);
  67. end;
  68.  
  69. PS = position_size("Fut", "Default", 100000, 40, atr, SL_ON * 0.00);
  70.  
  71. mpPrev = mp;
  72. mp = MarketPosition;
  73.  
  74. // ------------------------------------------
  75. // Exits
  76. //
  77. if mp = +1 then begin
  78.  
  79. TL = Round2Fraction(Close[0] - atr[0] * tl_mult);
  80. If BarsSinceEntry > 0 and TL < TL[1] then TL = TL[1];
  81.  
  82. if BarsSinceEntry = 0 or mp <> mpPrev then begin
  83. //PT = Round2Fraction(Close[0] + atr[0] * pt_mult);
  84. //SL = Round2Fraction(Close[0] - atr[0] * sl_mult);
  85. //TL = Round2Fraction(Close[0] - atr[0] * tl_mult);
  86. prof_x = 0;
  87. end;
  88.  
  89. // Profitable closes
  90. if isClose and Close >= EntryPrice then
  91. prof_x += 1;
  92. if BarsSinceEntry < Max_Time-1 and Profitable_Closes > 0 and prof_x >= Profitable_Closes then begin
  93. Sell ("ProfX") all contracts next bar market;
  94. PT = Round2Fraction(Close[0] + atr[0] * pt_mult);
  95. SL = Round2Fraction(Close[0] - atr[0] * sl_mult);
  96. TL = Round2Fraction(Close[0] - atr[0] * tl_mult);
  97. end;
  98. // Max bars in trade
  99. if BarsSinceEntry >= Max_Time-1 then begin
  100. Sell ("TimeX") all contracts next bar market;
  101. PT = Round2Fraction(Close[0] + atr[0] * pt_mult);
  102. SL = Round2Fraction(Close[0] - atr[0] * sl_mult);
  103. TL = Round2Fraction(Close[0] - atr[0] * tl_mult);
  104. prof_x = 0;
  105. end;
  106.  
  107. // Highest high
  108. if HH_ON = 1 then
  109. if isIBOG then
  110. Sell ("HHx ") all contracts next bar hh[1] limit
  111. else
  112. Sell ("HHx") all contracts next bar hh limit;
  113.  
  114. // Lowest Low
  115. if LL_ON = 1 then
  116. if isIBOG then
  117. Sell ("LLx ") all contracts next bar ll[1] stop
  118. else
  119. Sell ("LLx") all contracts next bar ll stop;
  120.  
  121. // Profit Target
  122. if PT_ON = 1 then
  123. Sell ("PTx") all contracts next bar PT limit;
  124. if PT_ON = 2 then
  125. setprofittarget(pt_mult);
  126.  
  127. // Stop Loss
  128. if SL_ON = 1 then
  129. Sell ("SLx") all contracts next bar SL stop;
  130. if SL_ON = 2 then
  131. setstoploss(sl_mult);
  132.  
  133. // Trail Loss
  134. If TL_ON = 1 then
  135. Sell ("TLx") all contracts next bar TL stop;
  136. If TL_ON = 2 then
  137. setdollartrailing(tl_mult);
  138.  
  139. // Force End of Day
  140. // if Time >= 1700 then Sell ("EODx") all contracts next bar market;
  141.  
  142. // Signal Exit
  143. //If BarsSinceEntry < Max_Time-1 and then begin
  144. // Sell ("SigX") all contracts next bar market;
  145. // PT = Round2Fraction(Close[0] + atr[0] * pt_mult);
  146. // SL = Round2Fraction(Close[0] - atr[0] * sl_mult);
  147. // TL = Round2Fraction(Close[0] - atr[0] * tl_mult);
  148. // prof_x = 0;
  149. //end;
  150.  
  151. end else
  152. if mp = -1 then begin
  153. end;
  154.  
  155. // -----------------------------------------
  156. // entry
  157. //
  158. if isClose then begin
  159. condition1 = low[2] <= high[6] and month(date) <> 12 and high[3] > close[8] and xaverage(close,50)[0] <= xaverage(close,200)[0];
  160. end;
  161.  
  162. if isClose and condition1[delay] then begin
  163. Buy ("Entry") PS contract next bar market;
  164.  
  165. if mp = 0 and isIBOG = false then begin
  166.  
  167. PT = Round2Fraction(Close[0] + atr[0] * pt_mult);
  168. SL = Round2Fraction(Close[0] - atr[0] * sl_mult);
  169. TL = Round2Fraction(Close[0] - atr[0] * tl_mult);
  170.  
  171. // Profit target
  172. if PT_ON = 1 then
  173. Sell ("PTx1") all contracts next bar PT limit;
  174. if PT_ON = 2 then
  175. setprofittarget(pt_mult);
  176.  
  177. // Stop loss
  178. if SL_ON = 1 then
  179. Sell ("SLx1") all contracts next bar SL stop;
  180. if SL_ON = 2 then
  181. setstoploss(sl_mult);
  182.  
  183. // Trail Loss
  184. If TL_ON = 1 then
  185. Sell ("TLx1") all contracts next bar TL stop;
  186. If TL_ON = 2 then
  187. setdollartrailing(tl_mult);
  188.  
  189. // Highest high
  190. if HH_ON = 1 then
  191. Sell ("HHx1") all contracts next bar hh limit;
  192.  
  193. // Lowest Low
  194. if LL_ON = 1 then
  195. Sell ("LLx1") all contracts next bar ll stop;
  196. end;
  197. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement