Excel VBA code (technical index for trading system)

Excel VBA Source Code --- PercentR(%R)

Technical code for trading system.

Sub PercentR()

'''-----http://www.samurai-logic.com/
'''-----Project of Trading System Development
'''------------------------------------------------------------------
''----B列(日付)、C列(始値)、D列(高値)、E列(安値)、F列(終値)
''----
''----TextBox1に計算期間
''--------------------------------------------------------------------

Dim length1%, length2%, i&, j&

Application.ScreenUpdating = False

Worksheets("%R").Activate
 
LastRow = Range("B4").End(xlDown).Row

length1 = CInt(ActiveSheet.TextBox1.Value)

Range("H5:H5000").ClearContents

Range("H3") = "%R:" & length1

For i = length1 + 5 To LastRow

   Cells(i, 8).Value = (Cells(i, 6).Value - _
   WorksheetFunction.Min(Range("E" & i - (length1) + 1, "E" & i))) * _
   100 / (WorksheetFunction.Max(Range("D" & i - (length1) + 1, "D" & i)) - _
   WorksheetFunction.Min(Range("E" & i - (length1) + 1, "E" & i)))

Next i

Range("H5", "H" & LastRow).NumberFormatLocal = "0.00"

Application.ScreenUpdating = True
End Sub