I'm attempting to determine the number of consecutive wins and losses. I get the number with my current code, but when I test its reliability with the total number of wins and losses, it doesn't match the total number of wins and losses shown by the strategy tester, so I'm not sure if it's giving me the right answer. `
print(string txt1, string txt2,string txt) =>
var table t = table.new(position.middle_right, 1, 3)
table.cell(t, 0, 0, txt1, bgcolor = color.rgb(0, 254, 21))
table.cell(t, 0, 1, txt2, bgcolor = color.rgb(0, 254, 21))
table.cell(t, 0, 2, txt, bgcolor = color.rgb(0, 254, 21))
print2(string txt) =>
var table t = table.new(position.top_right, 1, 1)
table.cell(t, 0, 0, txt, bgcolor = color.rgb(246, 4, 4))
newLoss = (strategy.losstrades > strategy.losstrades[1]) and (strategy.wintrades == strategy.wintrades[1]) and (strategy.eventrades == strategy.eventrades[1])
var streakLenloss = 0
var lossnum = 0
if (newLoss)
streakLenloss := streakLenloss + 1
else
if (strategy.wintrades > strategy.wintrades[1])
streakLenloss := 0
else
streakLenloss := streakLenloss
if ( streakLenloss>= 1)// or streakLenloss == 4 or streakLenloss == 8......
lossnum := lossnum+1
b = lossnum
print2(str.tostring(b))
`
Previously, I used the conditions below to calculate the total number of two consecutive losses, but when I tested the reliability of the last if statement with the above condition, it generated more losses than the total number of trades.
if ( streakLenloss== 2 or streakLenloss == 4 or streakLenloss == 6 or streakLenloss == 8 or streakLenloss == 10)