G
gtslabs
I am trying to make a way to test trading systems based on a
percentage of wins and losses and points won or loss. I wrote some
code to get a random win or loss. but I need a way to add this result
to a array and not allow any more events.
so if I have 10% of the time a loss of 2 points I need to keep track
of that and not allow any more in that group once the percentage of
total is achieved.
But all the groups must be filled based on the number of attempts.
Here is my code
Sub TradeSystem()
Dim MyValue
Dim TradeCount As Integer
Dim StockPrice As Single
Dim TradeSystem(1 To 5, 1 To 2)
'trading system - set by user
'% of Trades Points won/Loss
' 10% -2
' 25% -1
' 25% +1
' 20% +2
' 10% +3
'Total 100%
TradeSystem(1, 1) = Cells(3, 5)
TradeSystem(1, 2) = Cells(3, 6)
TradeSystem(2, 1) = Cells(4, 5)
TradeSystem(2, 2) = Cells(4, 6)
TradeSystem(3, 1) = Cells(5, 5)
TradeSystem(3, 2) = Cells(5, 6)
TradeSystem(4, 1) = Cells(6, 5)
TradeSystem(4, 2) = Cells(6, 6)
TradeSystem(5, 1) = Cells(7, 5)
TradeSystem(5, 2) = Cells(7, 6)
TradeCount = 50
For I = 1 To TradeCount
Randomize
'StockPrice = (100 * Rnd) ' Generate random value between 1 and
100.
Win_Loss = Rnd
If Win_Loss < 0.5 Then
pts = -Int(2 * Rnd + 1) ' Generate Pts from -2 to -1
Result = "Loss"
' how to add this result to the group (array)?
'and not allow any more once group is full
Else
Result = "win"
pts = Int((3 * Rnd) + 1) ' Generate points from 1 to 3
' how to add this result to group (array)?
'and not allow any more once group is full
End If
Debug.Print StockPrice, pts, Result
Next I
End Sub
percentage of wins and losses and points won or loss. I wrote some
code to get a random win or loss. but I need a way to add this result
to a array and not allow any more events.
so if I have 10% of the time a loss of 2 points I need to keep track
of that and not allow any more in that group once the percentage of
total is achieved.
But all the groups must be filled based on the number of attempts.
Here is my code
Sub TradeSystem()
Dim MyValue
Dim TradeCount As Integer
Dim StockPrice As Single
Dim TradeSystem(1 To 5, 1 To 2)
'trading system - set by user
'% of Trades Points won/Loss
' 10% -2
' 25% -1
' 25% +1
' 20% +2
' 10% +3
'Total 100%
TradeSystem(1, 1) = Cells(3, 5)
TradeSystem(1, 2) = Cells(3, 6)
TradeSystem(2, 1) = Cells(4, 5)
TradeSystem(2, 2) = Cells(4, 6)
TradeSystem(3, 1) = Cells(5, 5)
TradeSystem(3, 2) = Cells(5, 6)
TradeSystem(4, 1) = Cells(6, 5)
TradeSystem(4, 2) = Cells(6, 6)
TradeSystem(5, 1) = Cells(7, 5)
TradeSystem(5, 2) = Cells(7, 6)
TradeCount = 50
For I = 1 To TradeCount
Randomize
'StockPrice = (100 * Rnd) ' Generate random value between 1 and
100.
Win_Loss = Rnd
If Win_Loss < 0.5 Then
pts = -Int(2 * Rnd + 1) ' Generate Pts from -2 to -1
Result = "Loss"
' how to add this result to the group (array)?
'and not allow any more once group is full
Else
Result = "win"
pts = Int((3 * Rnd) + 1) ' Generate points from 1 to 3
' how to add this result to group (array)?
'and not allow any more once group is full
End If
Debug.Print StockPrice, pts, Result
Next I
End Sub