Looking for some help to clean up my code since it's not working like I want it to. What I'm trying to write is a basic martingale bot for a 1.5x method that doubles on loss, but then repeats the last bet after a win.
Example of what I'm trying to accomplish here.chance = 65
enablesrc=true
percentage=0.01
multiplier=2
base = balance*(percentage/100)
basebet = balance*(percentage/100)
nextbet = base
bethigh = false
function dobet()
if win then
nextbet = previousbet
if win then
nextbet = basebet
else
nextbet = previousbet*multiplier
end
else
nextbet = previousbet*multiplier
end
end
The double on loss works fine, but it keeps resetting to the base bet after the first win. Why is the "nextbet=previousbet" part not functioning like I want it to?
Also, setting my base bet as a percentage of my balance only does so at the start of running the script. It doesn't refresh after every cycle like I want it to. Any ideas if there's a fix for this too?
Your second if win statement is redundant. So on a win your script first sets nextbet to the previousbet and then sets it to the base bet. The else leg of that second if will never execute. If the bet won based on the first if statement it will always be a win in the second.
I think you want to change the second "if win" to "if currentstreak == 2 then" and get rid of the else path. That way on the first win currentstreak will be 1, and you will have set nextbet to the previousbet. But when you have 2 wins in a row it will bet the basebet.
as far as resetting the basebet based on balance. What point do you want to do that? after 1 win, only after 2 wins, or after more then 1 win. You would just copy your setting from above, and either put it after nextbet = previousbet if you want it for any win. Or after the nextbet = basebet in the second if statement, if you want it only after 2 wins in a row. If you want it after 2 or more wins. you could change the second if statement to check "if currentstreak > 1" that will cause that to execute each time you have more then 1 win in a row.
This is what I think your going for.
chance = 65
enablesrc=true
percentage=0.01
multiplier=2
base = balance*(percentage/100)
basebet = balance*(percentage/100)
nextbet = base
bethigh = false
function dobet()
if win then
nextbet = previousbet
if (currentstreak > 1)then
basebet = balance*(percentage/100) // if you put this here it updates basebet before setting nextbet
nextbet = basebet // if you move it after here, nextbet is still the old value, but the next time it will be updated
end
else
nextbet = previousbet*multiplier
end
end