Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/3252c52c4891507d6d4f07051b50e20d to your computer and use it in GitHub Desktop.
Save trycf/3252c52c4891507d6d4f07051b50e20d to your computer and use it in GitHub Desktop.
TryCF Gist
<cfset startingBalance = 3000.00>
<cfset numDays = 30>
<cfset pctToBet = .004>
<cfset pctToBet = .0059>
<cfset pctToBet = .0070>
<cfset pctToBet = .0035>
<cfset pctToBet = .02>
<cfset winsPerDay = 10>
<cfset balance1 = startingBalance>
<cfset totalWins1 = 0>
<!--- Calculate max number of times you can double your bet --->
<cfset maxDoubles = Floor( Log(1 / pctToBet) / Log(2) )>
<cfoutput>
<strong>Starting Balance:</strong> $#NumberFormat(startingBalance, ",0.00")#<br>
<strong>% to bet:</strong> #pctToBet#<br>
<strong>Wins Per Day:</strong> #winsPerDay#<br>
<strong>Total Days:</strong> #numDays#<br>
<strong>Max Bets with doubling:</strong> #maxDoubles#<br><br>
</cfoutput>
<!--- Loop through 30 days --->
<cfloop index="day" from="1" to="#numDays#">
<cfset dayStartBalance1 = balance1>
<!--- First bet of the day BEFORE any wins --->
<cfset firstBet1 = balance1 * pctToBet>
<cfset firstBet1 = val(numberFormat(firstBet1, "0.00"))>
<!--- Calculate max doubles today in case you want to show it per day --->
<cfset maxDoublesToday = Floor( Log(dayStartBalance1 / firstBet1) / Log(2) )>
<!--- Simulate winsPerDay wins for each scenario --->
<cfloop index="i" from="1" to="#winsPerDay#">
<!--- compounding bets throughout the day --->
<cfset initialBet1 = balance1 * pctToBet>
<cfset initialBet1 = val(numberFormat(initialBet1 - 0.01, "0.00"))>
<cfset initialBet1 = firstBet1>
<cfset balance1 += initialBet1>
<cfset totalWins1++>
</cfloop>
<!--- Daily Summary --->
<cfset dayProfit1 = balance1 - dayStartBalance1>
<cfset dayProfitPct1 = (dayProfit1 / dayStartBalance1) * 100>
<cfoutput>
<b>End of Day #day#</b>:
First Bet: $#NumberFormat(firstBet1, ",0.00")# |
Profit: $#NumberFormat(dayProfit1, ",0.00")# |
Balance: $#NumberFormat(balance1, ",0.00")# |
Max Bets with doubling: #maxDoublesToday#
&nbsp;&nbsp;&nbsp;+#NumberFormat(dayProfitPct1, "0")#%
<br>
</cfoutput>
</cfloop>
<cfoutput>
<br><strong>Final Totals after #numDays# days:</strong><br>
Wins: #totalWins1# | Final Balance: $#NumberFormat(balance1, ",0.00")#<br>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment