Look, even if i add an other condition to check if the first array have been updated, it leads to the same error even if i check if the index of the first array is filled with “isset” instruction… That means that the array is temporarly updated then deleted to come back to previous situation according to the real close at the end of the bar!
=> Thus the only way to prevent this bug if to send the variable index into an other variable (temp) which then will occurs only at the end of the bar, preventing the code to reach an index of the first array that have not been permanently filled yet.
Once RSILen = 14
Once prd = 1
Once pBcTi = -1
Once pBmTi = -1
src = RSI[RSILen](close)
If src[prd] = lowest[2*prd+1](src) then
pBcTi=pBcTi+1
$pBcT[pBcTi]= Barindex-1
if pBcTi > 2 and isset($pBcT[pBcTi]) then
if src[barindex-$pBcT[pBcTi-1]] <= src[barindex-$pBcT[pBcTi-2]] and src[barindex-$pBcT[pBcTi-1]] <= src[barindex-$pBcT[pBcTi]] then
pBmTi=pBmTi+1
$pBmT[pBmTi]= $pBcT[pBcTi-1]
drawpoint($pBcT[pBcTi-1],src[barindex-$pBcT[pBcTi-1]],3) coloured("red",100)
endif
endif
endif
Return src
I tried also using Lastset instruction… It does not solve the problem either!
Once RSILen = 14
Once prd = 1
Once pBcTi = -1
Once pBmTi = -1
src = RSI[RSILen](close)
If src[prd] = lowest[2*prd+1](src) then
pBcTi=pBcTi+1
$pBcT[pBcTi]= Barindex-1
if lastset($pBcT) > 2 then
if src[barindex-$pBcT[pBcTi-1]] <= src[barindex-$pBcT[pBcTi-2]] and src[barindex-$pBcT[pBcTi-1]] <= src[barindex-$pBcT[pBcTi]] then
pBmTi=pBmTi+1
$pBmT[pBmTi]= $pBcT[pBcTi-1]
drawpoint($pBcT[pBcTi-1],src[barindex-$pBcT[pBcTi-1]],3) coloured("red",100)
endif
endif
endif
Return src
But things get even stranger here below…
Once RSILen = 14
Once prd = 1
Once pBcTi = -1
Once pBmTi = -1
src = RSI[RSILen](close)
If src[prd] = lowest[2*prd+1](src) then
pBcTi=pBcTi+1
$pBcT[pBcTi]= Barindex-1
temp = pBcTi
if temp > 2 then
if src[barindex-$pBcT[pBcTi-1]] <= src[barindex-$pBcT[pBcTi-2]] and src[barindex-$pBcT[pBcTi-1]] <= src[barindex-$pBcT[pBcTi]] then
pBmTi=pBmTi+1
$pBmT[pBmTi]= $pBcT[pBcTi-1]
drawpoint($pBcT[pBcTi-1],src[barindex-$pBcT[pBcTi-1]],3) coloured("red",100)
endif
endif
endif
Return src
Can you explain that ? 🙂
Will we have something like PineScript instructions concerning bar state ?
barstate.isconfirmed for exmple? Because using multiple arrays, with arrays that are updated by other arrays lead to strange results…
https://www.tradingview.com/pine-script-docs/concepts/bar-states/#introduction
Thanks