automated trading - code vba 3


/ Published in: Visual Basic
Save to your folder(s)



Copy this code and paste it in your HTML
  1. '----------------------------
  2. ' xmean and slopexmean
  3. '----------------------------
  4. If i > 8 Then
  5. shtDB.Range("E1").Cells(i, 1).FormulaR1C1 = "=AVERAGE(R[-7]C[-4]:RC[-4])"
  6. shtDB.Range("E1").Cells(i, 1).Value = shtDB.Range("E1").Cells(i, 1).Value
  7.  
  8. 'shtDB.Range("K1").Cells(i, 1).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2" ' slope
  9. 'shtDB.Range("K1").Cells(i, 1).Value = shtDB.Range("K1").Cells(i, 1).Value
  10.  
  11. shtDB.Range("K1").Cells(i, 1).Value = Slope( _
  12. shtDB.Range("E1").Cells(i - 2, 1).Value, _
  13. shtDB.Range("E1").Cells(i - 1, 1).Value, _
  14. shtDB.Range("E1").Cells(i, 1).Value)
  15.  
  16. If i > 15 Then
  17. shtDB.Range("E1").Cells(i, 2).FormulaR1C1 = "=AVERAGE(R[-14]C[-5]:RC[-5])"
  18. shtDB.Range("E1").Cells(i, 2).Value = shtDB.Range("E1").Cells(i, 2).Value
  19.  
  20. 'shtDB.Range("K1").Cells(i, 2).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2" ' slope
  21. 'shtDB.Range("K1").Cells(i, 2).Value = shtDB.Range("K1").Cells(i, 2).Value
  22.  
  23. shtDB.Range("K1").Cells(i, 2).Value = Slope( _
  24. shtDB.Range("E1").Cells(i - 2, 2).Value, _
  25. shtDB.Range("E1").Cells(i - 1, 2).Value, _
  26. shtDB.Range("E1").Cells(i, 2).Value)
  27.  
  28. If i > 30 Then
  29. shtDB.Range("E1").Cells(i, 3).FormulaR1C1 = "=AVERAGE(R[-29]C[-6]:RC[-6])"
  30. shtDB.Range("E1").Cells(i, 3).Value = shtDB.Range("E1").Cells(i, 3).Value
  31.  
  32. 'shtDB.Range("K1").Cells(i, 3).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2" ' slope
  33. 'shtDB.Range("K1").Cells(i, 3).Value = shtDB.Range("K1").Cells(i, 3).Value
  34.  
  35. shtDB.Range("K1").Cells(i, 3).Value = Slope( _
  36. shtDB.Range("E1").Cells(i - 2, 3).Value, _
  37. shtDB.Range("E1").Cells(i - 1, 3).Value, _
  38. shtDB.Range("E1").Cells(i, 3).Value)
  39.  
  40. If i > 80 Then
  41. shtDB.Range("E1").Cells(i, 4).FormulaR1C1 = "=AVERAGE(R[-79]C[-7]:RC[-7])"
  42. shtDB.Range("E1").Cells(i, 4).Value = shtDB.Range("E1").Cells(i, 4).Value
  43.  
  44. 'shtDB.Range("K1").Cells(i, 4).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2" ' slope
  45. 'shtDB.Range("K1").Cells(i, 4).Value = shtDB.Range("K1").Cells(i, 4).Value
  46.  
  47. shtDB.Range("K1").Cells(i, 4).Value = Slope( _
  48. shtDB.Range("E1").Cells(i - 2, 4).Value, _
  49. shtDB.Range("E1").Cells(i - 1, 4).Value, _
  50. shtDB.Range("E1").Cells(i, 4).Value)
  51.  
  52. If i > 110 Then
  53. shtDB.Range("E1").Cells(i, 5).FormulaR1C1 = "=AVERAGE(R[-109]C[-8]:RC[-8])"
  54. shtDB.Range("E1").Cells(i, 5).Value = shtDB.Range("E1").Cells(i, 5).Value
  55.  
  56. 'shtDB.Range("K1").Cells(i, 5).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2" ' slope
  57. 'shtDB.Range("K1").Cells(i, 5).Value = shtDB.Range("K1").Cells(i, 5).Value
  58.  
  59. shtDB.Range("K1").Cells(i, 5).Value = Slope( _
  60. shtDB.Range("E1").Cells(i - 2, 5).Value, _
  61. shtDB.Range("E1").Cells(i - 1, 5).Value, _
  62. shtDB.Range("E1").Cells(i, 5).Value)
  63.  
  64. If i > 200 Then
  65. shtDB.Range("E1").Cells(i, 6).FormulaR1C1 = "=AVERAGE(R[-199]C[-9]:RC[-9])"
  66. shtDB.Range("E1").Cells(i, 6).Value = shtDB.Range("E1").Cells(i, 6).Value
  67.  
  68. 'shtDB.Range("K1").Cells(i, 6).FormulaR1C1 = "=(RC[-6]-R[-2]C[-6])/2" ' slope
  69. 'shtDB.Range("K1").Cells(i, 6).Value = shtDB.Range("K1").Cells(i, 6).Value
  70.  
  71. shtDB.Range("K1").Cells(i, 6).Value = Slope( _
  72. shtDB.Range("E1").Cells(i - 2, 6).Value, _
  73. shtDB.Range("E1").Cells(i - 1, 6).Value, _
  74. shtDB.Range("E1").Cells(i, 6).Value)
  75. End If
  76. End If
  77. End If
  78. End If
  79. End If
  80. End If

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.