Positive Integer error when using lowest
Forums › ProRealTime English forum › ProBuilder support › Positive Integer error when using lowest
- This topic has 8 replies, 3 voices, and was last updated 4 years ago by Vonasi.
-
-
04/02/2020 at 5:19 AM #124300
Hi,
I am using the below code as a trailing stop on the US500 but keep getting a positive integer error. When I remove line 9 indicator i5, it seems to work but I dont understand why it doesnt when included.
I think i have accounted for negatives and also used round() to account for decimals.
Any help would be appreciated.
Thanks
Carter
123456789101112131415161718i1 = close - 2491//2491 is purchase price, will use postiionprice in backtesti2 = 250 - (i1 * 3)//250 is an optimized numberif i2 < 1 theni2 = 2endifi4 = round(i2)i5 = lowest[10](i4)// to delay fall of lowest valueif i1 > 3 theni6 = i5elsei6 = 700//optimized value stop when in lossendifi7 = lowest[i6](low)return i7[1]04/02/2020 at 7:40 AM #12430304/02/2020 at 7:56 AM #12430504/02/2020 at 8:24 AM #124309Try this at line 8:
1i4 = max(1,round(i2))to make sure it’s not 0.
04/02/2020 at 8:42 AM #12431204/02/2020 at 8:45 AM #12431404/02/2020 at 9:06 AM #124315Try this:
12345678910111213141516171819202122if barindex > 10 theni1 = close - 2491//2491 is purchase price, will use postiionprice in backtesti2 = 250 - (i1 * 3)//250 is an optimized numberif i2 <= 1 theni2 = 2endifi4 = max(1,i4)//round(i2)i5 = lowest[10](i4)// to delay fall of lowest valueif i1 > 3 theni6 = i5elsei6 = 700//optimized value stop when in lossendifi6 = max(1,i6)i7 = lowest[i6](low)endifreturn i7[1]04/02/2020 at 9:37 AM #124316Yes it seems to work, i had to change a couple of values though.
I tried it with the barindex and with out and it didnt work with out, what is the thought process behind that. I dont understand.
Thanks for your help
Trailing Stop12345678910111213141516171819202122if barindex > 10 theni1 = close - 2491//2491 is purchase price, will use postiionprice in backtesti2 = 250 - (i1 * 3)//250 is an optimized number//if i2 <= 1 then//i2 = 2//endifi4 = max(1,round(i2))//round(i2)i5 = lowest[10](i4)// to delay fall of lowest valueif i1 > 3 theni6 = i5elsei6 = 700//optimized value stop when in lossendifi7 = max(1,i6)i8 = lowest[i7](low)endifreturn i8[1]04/02/2020 at 9:50 AM #124321It is a common fix. When you first launch the indicator it checks the first bar and then tries to look for lows on the previous 9 bars that don’t exist. The error message I think is a little incorrect as to how it describes the problem. It is always a good idea to make sure there are enough bars on your chart to actually get a meaningful result. However if the indicator is used in a strategy then it means that you have a pause at the start of every back test before trading can start.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on