Advertisement
Guest User

Untitled

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