Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Help with random numbers in gaming system

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with random numbers in gaming system

Your approach is wrong. Create a random number 0 <= x < 1.00

If random number is the following range do the following

0.00 <= X < .1 -2 10%
0.10 <= X < .35 -1 25%
0.35 <= X < .6 +1 25%
0.80 <= X < .9 -2 20%
0.90 <= X < 1.0 ? 10%

Start with a number of points like 100 and stop when you get to zero
indicating you ran out of money



"gtslabs" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default Help with random numbers in gaming system

Hello,

You can usse my UDF rww or redw for this:
http://www.sulprobil.com/html/distributions.html

Regards,
Bernd
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Help with random numbers in gaming system

On Mar 4, 12:11*pm, Bernd P wrote:
Hello,

You can usse my UDF rww or redw for this:http://www.sulprobil.com/html/distributions.html

Regards,
Bernd


Thanks - that is great!
I am getting my critera from my worksheet.
I have the default bins set to 5.
If I only need 4 inputs but want to keep all 5 (dont want to change
formula)should I pass 0 or Null (empty cells)?
I noticed a difference in the 2 approaches
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default Help with random numbers in gaming system

Hello,

Hmm, there should be no difference but 0 should do it.

Send me an example with the spotted difference, please.

Regards,
Bernd


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Excel pick random numbers from 1-300 and not repeat numbers? Julian Excel Discussion (Misc queries) 1 June 7th 06 07:17 AM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM
Microsoft_Sale ,Software,Hardware,Visual,Gaming sharon Excel Programming 0 August 7th 03 04:00 AM
Microsoft_Sale ,Software,Hardware,Visual,Gaming sharon Excel Programming 0 August 7th 03 04:00 AM


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"