Advertisement
Guest User

algo 37 hhh

a guest
Jan 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. {*
  2. ========================================================================
  3. Strategy: @@Team47_StrMultipleTimeFrames
  4.  
  5.  
  6.  
  7.  
  8. ========================================================================
  9. *}
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. {*
  17. ========================================================================
  18. === Input Parameters
  19. ========================================================================
  20. *}
  21. Input:
  22. INT n(3), // n - barinterval multiplier
  23. INT k_Length(8), // k - sequence length
  24. INT m_Bars(8), // m - max number of bars in position
  25. FLOAT ProfitPct(20.0); // Profit %
  26.  
  27. {*
  28. ======================================================================================================
  29. === Start of Implementation
  30. ======================================================================================================
  31. *}
  32.  
  33. // Constants ----------------------------------------------------------
  34. //-----------------------------------------------------------------------
  35. Constants:
  36. INT DataArraySize(50);
  37.  
  38.  
  39. //----------------------------------------------------------------------
  40. // Data Processing
  41. //----------------------------------------------------------------------
  42.  
  43. Array:
  44. Data2BarsHigh[DataArraySize](0),
  45. Data2BarsLow[DataArraySize](0)
  46.  
  47. Data1BarsHigh[DataArraySize*n](0),
  48. Data1BarsLow[DataArraySize*n](0),
  49.  
  50. Data2BarsClose[DataArraySize](0);
  51.  
  52.  
  53. Data2BarsHigh[BarNumber[0]]=high;
  54. Data2BarsLow[BarNumber[0]]=low;
  55.  
  56. if BarNumber[0]%n=0 then begin
  57. Data2BarsHigh[BarNumber[0]/n]=high;
  58. Data2BarsLow[BarNumber[0]/n]=low;
  59. Data2BarsClose[BarNumber[0]/n] = close;
  60. end;
  61.  
  62.  
  63. // Data2 Construction --------------------------------------------------
  64. //----------------------------------------------------------------------
  65.  
  66.  
  67.  
  68. //----------------------------------------------------------------------
  69.  
  70.  
  71. //----------------------------------------------------------------------
  72. // END - Data Processing -----------------------------------------------
  73. //----------------------------------------------------------------------
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. //----------------------------------------------------------------------
  81. // Events Identification
  82. //----------------------------------------------------------------------
  83.  
  84.  
  85. // Check k-High Sequence -----------------------------------------------
  86. //----------------------------------------------------------------------
  87. Vars:
  88. BOOL k_SequenceFound(FALSE);
  89. INT num_of_last_bar_selled(DataArraySize);
  90.  
  91. k_SequenceFound=TRUE;
  92. for j=0 to k_Length-1 begin
  93. if Data2BarsHigh[((BarNumber[1])/n)-(j+1)]>Data2BarsHigh[(BarNumber[1])/n-j] then begin
  94. k_SequenceFound = FALSE;
  95. end;
  96. end;
  97.  
  98.  
  99.  
  100.  
  101.  
  102. //k_SequenceFound = TRUE/FALSE;
  103.  
  104.  
  105.  
  106. //----------------------------------------------------------------------
  107. // End::Events Identification
  108. //----------------------------------------------------------------------
  109.  
  110.  
  111. //----------------------------------------------------------------------
  112. // Strategy
  113. //----------------------------------------------------------------------
  114.  
  115.  
  116. // Short Entry ---------------------------------------------------------
  117. //----------------------------------------------------------------------
  118.  
  119. if k_SequenceFound=TRUE AND Data2BarsLow[((BarNumber[1])/n)] = 0.05+Data1BarsLow[(BarNumber[0])] and (BarNumber[1])%n=0) then begin
  120. sellshort this bar at Market;
  121. num_of_last_bar_selled = BarNumber[0];
  122. end;
  123. //----------------------------------------------------------------------
  124.  
  125.  
  126. // Short Exit ----------------------------------------------------------
  127. //----------------------------------------------------------------------
  128. if ProfitPct < (Data2BarsClose[(BarNumber[1])/n] -Data2BarsClose[((BarNumber[1])/n )+1])/Data2BarsClose[(BarNumber[1])/n]) OR num_of_last_bar_selled+m_Bars = BarNumber[0] then begin
  129. BuyToCover this bar at Market;
  130. end;
  131.  
  132.  
  133. //----------------------------------------------------------------------
  134.  
  135.  
  136.  
  137.  
  138. // StopLoss Exit
  139. //----------------------------------------------------------------------
  140. SetStopShare;
  141. if Data2BarsHigh[(num_of_last_bar_selled-1)/n]-0.02>high) then begin
  142. BuyToCover this bar at Market;
  143. end;
  144. //----------------------------------------------------------------------
  145.  
  146.  
  147.  
  148. //----------------------------------------------------------------------
  149. // End:: Strategy
  150. //----------------------------------------------------------------------
  151.  
  152. {*
  153. ======================================================================================================
  154. === End of Implementation
  155. ======================================================================================================
  156. *}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement