Here it is:
Master Macro:
'TESTING THE 55-DAY SYSTEM:
Sub test_55_day_system()
'establishing the last row of historical price data
last_row = Worksheets("Sheet1").Range("D29").Value
'cycle throught every row of data:
For j = 1 To last_row
'updating the spinner cell value:
Worksheets("Sheet1").Range("E29").Value = Worksheets("Sheet1").Range("E29").Value + 1
'checking to see if a buy or sell signal is given:
signal = Worksheets("Sheet1").Range("K41").Value
If signal = 1 Then
'entering long trade:
Application.Run "test_55_day_long_system"
End If
If signal = -1 Then
'entering short trade:
Application.Run "test_55_day_short_system"
End If
'close the for loop
Next
End Sub
Functions 1 and 2:
'TESTING THE 55-DAY LONG SYSTEM:
Sub test_55_day_long_system()
'setting 'intrade' value to 0 to indicate that trade has not taken place
intrade = 0
'entering trade:
Application.Run "Long_55_day_enter"
'setting 'intrade' value to 1 to avoid looking at entry signals:
intrade = 1
'checking to see if stops are hit. If hit the loop exits:
Do While intrade = 1
'checking to see if a 2% stop loss was hit (placed ahead of profit stop to insure
'that if a 20-day low is hit at the same time as the 2% stop, 2% will be recorded
'over the profit stop
profit_exit_signal = Worksheets("Sheet1").Range("I54").Value
If profit_exit_signal = 1 Then
Application.Run "Long_55_day_profit_exit"
intrade = 0
End If
'checking to see if a 2% stop loss was hit
stop_loss_signal = Worksheets("Sheet1").Range("I48").Value
If stop_loss_signal = 1 Then
Application.Run "Long_55_day_stop_exit"
intrade = 0
End If
' recording next row of data to read:
If intrade = 1 Then
Worksheets("Sheet1").Range("E29").Value = Worksheets("Sheet1").Range("E29").Value + 1
End If
'ends the stop loop as soon as intrade = 0 (stop is hit) or there is no more data
Loop
'recording new position of spinner once trade has been exited:
Worksheets("Sheet1").Range("E29").Value = Worksheets("Sheet1").Range("E29").Value + 1
'sending back to the main test_55_day_system macro
Application.Run "test_55_day_system"
End Sub
'TESTING THE 55-DAY SHORT SYSTEM:
Sub test_55_day_short_system()
'setting 'intrade' value to 0 to indicate that trade has not taken place
intrade = 0
'entering the trade:
Application.Run "Short_55_day_enter"
'setting 'intrade' value to 1 to avoid looking at entry signals:
intrade = 1
'checking to see if stops are hit. If hit the loop exits:
Do While intrade = 1
'checking to see if a 2% stop loss was hit (placed ahead of profit stop to insure
'that if a 20-day low is hit at the same time as the 2% stop, 2% will be recorded
'over the profit stop
profit_exit_signal = Worksheets("Sheet1").Range("J54").Value
If profit_exit_signal = 1 Then
Application.Run "Short_55_day_profit_exit"
intrade = 0
End If
'checking to see if a 2% stop loss was hit
stop_loss_signal = Worksheets("Sheet1").Range("J48").Value
If stop_loss_signal = 1 Then
Application.Run "Short_55_day_stop_exit"
intrade = 0
End If
' recording next row of data to read:
If intrade = 1 Then
Worksheets("Sheet1").Range("E29").Value = Worksheets("Sheet1").Range("E29").Value + 1
End If
'ends the stop loop as soon as intrade = 0 (stop is hit) or there is no more data
Loop
'recording new position of spinner once trade has been exited:
Worksheets("Sheet1").Range("E29").Value = Worksheets("Sheet1").Range("E29").Value + 1
'sending back to the main test_55_day_system macro
Application.Run "test_55_day_system"
End Sub
Bookmarks