Martingale script?
1KYREYDYgEdbuE4BLMRY556Kx8zPbry6j8
R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-apple-darwin9.8.0/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[R.app GUI 1.52 (6188) i386-apple-darwin9.8.0]
>
>
> #reports strategy parameters
> strategy.func <- function(r, bets, max, p){
+ m <- 1 / (1 - 1 / r)
+ n <- round(-log (bets * p + 1)/log(1 - p))
+ init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
+ pc.loss <- (1 - (init*m^n*r - 0.0005)/(init*m^n*r)) * 100
+ return(noquote(paste("m =",m," | init =",init," | percentage loss to fees =",pc.loss,"%.")))
+ }
>
>
> #reports order of martingale betting
> allbets.func <- function(r, bets, max, p){
+ m <- 1 / (1 - 1 / r)
+ n <- round(-log (bets * p + 1)/log(1 - p))
+ init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
+ mat <- matrix(c(1:bets,round(init*m^(1:bets), 6)),bets,2)
+ colnames(mat)<-c("bet number", "bet amount" )
+ return(mat)
+ }
>
> #change these variables to suit
> r <- 8
> p <- 8000/65536
> bets <- 100
> max <- 1
>
> strategy.func(r, bets, max, p)
[1] m = 1.14285714285714 | init = 0.00924140314804633 | percentage loss to fees = 0.0468061760111049 %.
>
> allbets.func(r, bets, max, p)
bet number bet amount
[1,] 1 0.010562
[2,] 2 0.012070
[3,] 3 0.013795
[4,] 4 0.015765
[5,] 5 0.018018
[6,] 6 0.020592
[7,] 7 0.023533
[8,] 8 0.026895
[9,] 9 0.030737
[10,] 10 0.035128
[11,] 11 0.040147
[12,] 12 0.045882
[13,] 13 0.052436
[14,] 14 0.059927
[15,] 15 0.068488
[16,] 16 0.078272
[17,] 17 0.089454
[18,] 18 0.102233
[19,] 19 0.116838
[20,] 20 0.133529
[21,] 21 0.152605
[22,] 22 0.174406
[23,] 23 0.199321
[24,] 24 0.227795
[25,] 25 0.260337
[26,] 26 0.297528
[27,] 27 0.340033
[28,] 28 0.388609
[29,] 29 0.444124
[30,] 30 0.507570
[31,] 31 0.580081
[32,] 32 0.662949
[33,] 33 0.757656
[34,] 34 0.865893
[35,] 35 0.989592
[36,] 36 1.130962
[37,] 37 1.292528
[38,] 38 1.477175
[39,] 39 1.688200
[40,] 40 1.929371
[41,] 41 2.204996
[42,] 42 2.519995
[43,] 43 2.879994
[44,] 44 3.291422
[45,] 45 3.761625
[46,] 46 4.299000
[47,] 47 4.913143
[48,] 48 5.615021
[49,] 49 6.417167
[50,] 50 7.333905
[51,] 51 8.381605
[52,] 52 9.578978
[53,] 53 10.947403
[54,] 54 12.511318
[55,] 55 14.298649
[56,] 56 16.341313
[57,] 57 18.675786
[58,] 58 21.343756
[59,] 59 24.392864
[60,] 60 27.877558
[61,] 61 31.860067
[62,] 62 36.411505
[63,] 63 41.613148
[64,] 64 47.557884
[65,] 65 54.351867
[66,] 66 62.116420
[67,] 67 70.990194
[68,] 68 81.131650
[69,] 69 92.721886
[70,] 70 105.967870
[71,] 71 121.106137
[72,] 72 138.407014
[73,] 73 158.179444
[74,] 74 180.776508
[75,] 75 206.601723
[76,] 76 236.116255
[77,] 77 269.847149
[78,] 78 308.396741
[79,] 79 352.453419
[80,] 80 402.803907
[81,] 81 460.347323
[82,] 82 526.111226
[83,] 83 601.269972
[84,] 84 687.165683
[85,] 85 785.332209
[86,] 86 897.522524
[87,] 87 1025.740028
[88,] 88 1172.274317
[89,] 89 1339.742077
[90,] 90 1531.133802
[91,] 91 1749.867203
[92,] 92 1999.848232
[93,] 93 2285.540836
[94,] 94 2612.046670
[95,] 95 2985.196194
[96,] 96 3411.652793
[97,] 97 3899.031764
[98,] 98 4456.036301
[99,] 99 5092.612916
[100,] 100 5820.129047
>
>
>
> #reports strategy parameters
> strategy.func <- function(r, bets, max, p){
+ m <- 1 / (1 - 1 / r)
+ n <- round(-log (bets * p + 1)/log(1 - p))
+ init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
+ pc.loss <- (1 - (init*m^n*r - 0.0005)/(init*m^n*r)) * 100
+ return(noquote(paste("m =",m," | init =",init," | percentage loss to fees =",pc.loss,"%.")))
+ }
>
>
> #reports order of martingale betting
> allbets.func <- function(r, bets, max, p){
+ m <- 1 / (1 - 1 / r)
+ n <- round(-log (bets * p + 1)/log(1 - p))
+ init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
+ mat <- matrix(c(1:bets,round(init*m^(1:bets), 6)),bets,2)
+ colnames(mat)<-c("bet number", "bet amount" )
+ return(mat)
+ }
>
> #change these variables to suit
> r <- 2
> p <- 8000/65536
> bets <- 100
> max <- 1
>
> strategy.func(r, bets, max, p)
[1] m = 2 | init = 4.73252366609602e-07 | percentage loss to fees = 0.0503787399542377 %.
>
> allbets.func(r, bets, max, p)
bet number bet amount
[1,] 1 1.000000e-06
[2,] 2 2.000000e-06
[3,] 3 4.000000e-06
[4,] 4 8.000000e-06
[5,] 5 1.500000e-05
[6,] 6 3.000000e-05
[7,] 7 6.100000e-05
[8,] 8 1.210000e-04
[9,] 9 2.420000e-04
[10,] 10 4.850000e-04
[11,] 11 9.690000e-04
[12,] 12 1.938000e-03
[13,] 13 3.877000e-03
[14,] 14 7.754000e-03
[15,] 15 1.550800e-02
[16,] 16 3.101500e-02
[17,] 17 6.203000e-02
[18,] 18 1.240600e-01
[19,] 19 2.481210e-01
[20,] 20 4.962410e-01
[21,] 21 9.924820e-01
[22,] 22 1.984964e+00
[23,] 23 3.969929e+00
[24,] 24 7.939857e+00
[25,] 25 1.587971e+01
[26,] 26 3.175943e+01
[27,] 27 6.351886e+01
[28,] 28 1.270377e+02
[29,] 29 2.540754e+02
[30,] 30 5.081509e+02
[31,] 31 1.016302e+03
[32,] 32 2.032603e+03
[33,] 33 4.065207e+03
[34,] 34 8.130414e+03
[35,] 35 1.626083e+04
[36,] 36 3.252165e+04
[37,] 37 6.504331e+04
[38,] 38 1.300866e+05
[39,] 39 2.601732e+05
[40,] 40 5.203465e+05
[41,] 41 1.040693e+06
[42,] 42 2.081386e+06
[43,] 43 4.162772e+06
[44,] 44 8.325544e+06
[45,] 45 1.665109e+07
[46,] 46 3.330217e+07
[47,] 47 6.660435e+07
[48,] 48 1.332087e+08
[49,] 49 2.664174e+08
[50,] 50 5.328348e+08
[51,] 51 1.065670e+09
[52,] 52 2.131339e+09
[53,] 53 4.262678e+09
[54,] 54 8.525357e+09
[55,] 55 1.705071e+10
[56,] 56 3.410143e+10
[57,] 57 6.820285e+10
[58,] 58 1.364057e+11
[59,] 59 2.728114e+11
[60,] 60 5.456228e+11
[61,] 61 1.091246e+12
[62,] 62 2.182491e+12
[63,] 63 4.364983e+12
[64,] 64 8.729965e+12
[65,] 65 1.745993e+13
[66,] 66 3.491986e+13
[67,] 67 6.983972e+13
[68,] 68 1.396794e+14
[69,] 69 2.793589e+14
[70,] 70 5.587178e+14
[71,] 71 1.117436e+15
[72,] 72 2.234871e+15
[73,] 73 4.469742e+15
[74,] 74 8.939484e+15
[75,] 75 1.787897e+16
[76,] 76 3.575794e+16
[77,] 77 7.151588e+16
[78,] 78 1.430318e+17
[79,] 79 2.860635e+17
[80,] 80 5.721270e+17
[81,] 81 1.144254e+18
[82,] 82 2.288508e+18
[83,] 83 4.577016e+18
[84,] 84 9.154032e+18
[85,] 85 1.830806e+19
[86,] 86 3.661613e+19
[87,] 87 7.323226e+19
[88,] 88 1.464645e+20
[89,] 89 2.929290e+20
[90,] 90 5.858581e+20
[91,] 91 1.171716e+21
[92,] 92 2.343432e+21
[93,] 93 4.686864e+21
[94,] 94 9.373729e+21
[95,] 95 1.874746e+22
[96,] 96 3.749492e+22
[97,] 97 7.498983e+22
[98,] 98 1.499797e+23
[99,] 99 2.999593e+23
[100,] 100 5.999186e+23
>
> >
Error: unexpected '>' in ">"
>
> #reports strategy parameters
> strategy.func <- function(r, bets, max, p){
+ m <- 1 / (1 - 1 / r)
+ n <- round(-log (bets * p + 1)/log(1 - p))
+ init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
+ pc.loss <- (1 - (init*m^n*r - 0.0005)/(init*m^n*r)) * 100
+ return(noquote(paste("m =",m," | init =",init," | percentage loss to fees =",pc.loss,"%.")))
+ }
>
>
> #reports order of martingale betting
> allbets.func <- function(r, bets, max, p){
+ m <- 1 / (1 - 1 / r)
+ n <- round(-log (bets * p + 1)/log(1 - p))
+ init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
+ mat <- matrix(c(1:bets,round(init*m^(1:bets), 6)),bets,2)
+ colnames(mat)<-c("bet number", "bet amount" )
+ return(mat)
+ }
>
> #change these variables to suit
> r <- 2p <- 8000/65536
Error: unexpected symbol in "r <- 2p"
> bets <- 100
> max <- 100
>
> strategy.func(r, bets, max, p)
[1] m = 2 | init = 4.77984890275698e-05 | percentage loss to fees = 0.00049879940549058 %.
>
> allbets.func(r, bets, max, p)
bet number bet amount
[1,] 1 9.600000e-05
[2,] 2 1.910000e-04
[3,] 3 3.820000e-04
[4,] 4 7.650000e-04
[5,] 5 1.530000e-03
[6,] 6 3.059000e-03
[7,] 7 6.118000e-03
[8,] 8 1.223600e-02
[9,] 9 2.447300e-02
[10,] 10 4.894600e-02
[11,] 11 9.789100e-02
[12,] 12 1.957830e-01
[13,] 13 3.915650e-01
[14,] 14 7.831300e-01
[15,] 15 1.566261e+00
[16,] 16 3.132522e+00
[17,] 17 6.265044e+00
[18,] 18 1.253009e+01
[19,] 19 2.506017e+01
[20,] 20 5.012035e+01
[21,] 21 1.002407e+02
[22,] 22 2.004814e+02
[23,] 23 4.009628e+02
[24,] 24 8.019256e+02
[25,] 25 1.603851e+03
[26,] 26 3.207702e+03
[27,] 27 6.415405e+03
[28,] 28 1.283081e+04
[29,] 29 2.566162e+04
[30,] 30 5.132324e+04
[31,] 31 1.026465e+05
[32,] 32 2.052929e+05
[33,] 33 4.105859e+05
[34,] 34 8.211718e+05
[35,] 35 1.642344e+06
[36,] 36 3.284687e+06
[37,] 37 6.569374e+06
[38,] 38 1.313875e+07
[39,] 39 2.627750e+07
[40,] 40 5.255499e+07
[41,] 41 1.051100e+08
[42,] 42 2.102200e+08
[43,] 43 4.204400e+08
[44,] 44 8.408799e+08
[45,] 45 1.681760e+09
[46,] 46 3.363520e+09
[47,] 47 6.727039e+09
[48,] 48 1.345408e+10
[49,] 49 2.690816e+10
[50,] 50 5.381631e+10
[51,] 51 1.076326e+11
[52,] 52 2.152653e+11
[53,] 53 4.305305e+11
[54,] 54 8.610610e+11
[55,] 55 1.722122e+12
[56,] 56 3.444244e+12
[57,] 57 6.888488e+12
[58,] 58 1.377698e+13
[59,] 59 2.755395e+13
[60,] 60 5.510791e+13
[61,] 61 1.102158e+14
[62,] 62 2.204316e+14
[63,] 63 4.408632e+14
[64,] 64 8.817265e+14
[65,] 65 1.763453e+15
[66,] 66 3.526906e+15
[67,] 67 7.053812e+15
[68,] 68 1.410762e+16
[69,] 69 2.821525e+16
[70,] 70 5.643050e+16
[71,] 71 1.128610e+17
[72,] 72 2.257220e+17
[73,] 73 4.514440e+17
[74,] 74 9.028879e+17
[75,] 75 1.805776e+18
[76,] 76 3.611552e+18
[77,] 77 7.223103e+18
[78,] 78 1.444621e+19
[79,] 79 2.889241e+19
[80,] 80 5.778483e+19
[81,] 81 1.155697e+20
[82,] 82 2.311393e+20
[83,] 83 4.622786e+20
[84,] 84 9.245572e+20
[85,] 85 1.849114e+21
[86,] 86 3.698229e+21
[87,] 87 7.396458e+21
[88,] 88 1.479292e+22
[89,] 89 2.958583e+22
[90,] 90 5.917166e+22
[91,] 91 1.183433e+23
[92,] 92 2.366867e+23
[93,] 93 4.733733e+23
[94,] 94 9.467466e+23
[95,] 95 1.893493e+24
[96,] 96 3.786986e+24
[97,] 97 7.573973e+24
[98,] 98 1.514795e+25
[99,] 99 3.029589e+25
[100,] 100 6.059178e+25
>
> #reports strategy parameters
> strategy.func <- function(r, bets, max, p){
+ m <- 1 / (1 - 1 / r)
+ n <- round(-log (bets * p + 1)/log(1 - p))
+ init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
+ pc.loss <- (1 - (init*m^n*r - 0.0005)/(init*m^n*r)) * 100
+ return(noquote(paste("m =",m," | init =",init," | percentage loss to fees =",pc.loss,"%.")))
+ }
>
>
> #reports order of martingale betting
> allbets.func <- function(r, bets, max, p){
+ m <- 1 / (1 - 1 / r)
+ n <- round(-log (bets * p + 1)/log(1 - p))
+ init <- (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
+ mat <- matrix(c(1:bets,round(init*m^(1:bets), 6)),bets,2)
+ colnames(mat)<-c("bet number", "bet amount" )
+ return(mat)
+ }
>
> #change these variables to suit
> r <- 8
> p <- 8000/65536
> bets <- 100
> max <- 1
>
> strategy.func(r, bets, max, p)
[1] m = 1.14285714285714 | init = 0.00924140314804633 | percentage loss to fees = 0.0468061760111049 %.
>
> allbets.func(r, bets, max, p)
bet number bet amount
[1,] 1 0.010562
[2,] 2 0.012070
[3,] 3 0.013795
[4,] 4 0.015765
[5,] 5 0.018018
[6,] 6 0.020592
[7,] 7 0.023533
[8,] 8 0.026895
[9,] 9 0.030737
[10,] 10 0.035128
[11,] 11 0.040147
[12,] 12 0.045882
[13,] 13 0.052436
[14,] 14 0.059927
[15,] 15 0.068488
[16,] 16 0.078272
[17,] 17 0.089454
[18,] 18 0.102233
[19,] 19 0.116838
[20,] 20 0.133529
[21,] 21 0.152605
[22,] 22 0.174406
[23,] 23 0.199321
[24,] 24 0.227795
[25,] 25 0.260337
[26,] 26 0.297528
[27,] 27 0.340033
[28,] 28 0.388609
[29,] 29 0.444124
[30,] 30 0.507570
[31,] 31 0.580081
[32,] 32 0.662949
[33,] 33 0.757656
[34,] 34 0.865893
[35,] 35 0.989592
[36,] 36 1.130962
[37,] 37 1.292528
[38,] 38 1.477175
[39,] 39 1.688200
[40,] 40 1.929371
[41,] 41 2.204996
[42,] 42 2.519995
[43,] 43 2.879994
[44,] 44 3.291422
[45,] 45 3.761625
[46,] 46 4.299000
[47,] 47 4.913143
[48,] 48 5.615021
[49,] 49 6.417167
[50,] 50 7.333905
[51,] 51 8.381605
[52,] 52 9.578978
[53,] 53 10.947403
[54,] 54 12.511318
[55,] 55 14.298649
[56,] 56 16.341313
[57,] 57 18.675786
[58,] 58 21.343756
[59,] 59 24.392864
[60,] 60 27.877558
[61,] 61 31.860067
[62,] 62 36.411505
[63,] 63 41.613148
[64,] 64 47.557884
[65,] 65 54.351867
[66,] 66 62.116420
[67,] 67 70.990194
[68,] 68 81.131650
[69,] 69 92.721886
[70,] 70 105.967870
[71,] 71 121.106137
[72,] 72 138.407014
[73,] 73 158.179444
[74,] 74 180.776508
[75,] 75 206.601723
[76,] 76 236.116255
[77,] 77 269.847149
[78,] 78 308.396741
[79,] 79 352.453419
[80,] 80 402.803907
[81,] 81 460.347323
[82,] 82 526.111226
[83,] 83 601.269972
[84,] 84 687.165683
[85,] 85 785.332209
[86,] 86 897.522524
[87,] 87 1025.740028
[88,] 88 1172.274317
[89,] 89 1339.742077
[90,] 90 1531.133802
[91,] 91 1749.867203
[92,] 92 1999.848232
[93,] 93 2285.540836
[94,] 94 2612.046670
[95,] 95 2985.196194
[96,] 96 3411.652793
[97,] 97 3899.031764
[98,] 98 4456.036301
[99,] 99 5092.612916
[100,] 100 5820.129047
>
>
>
>