Hello all. Here's a simple example of a problem I have encountered with an intermittent intrabar meeting of an indicator's interbar criteria and what seems to me the inadequacy of using Computeonclose or BarState to solve this problem. Suppose I wanted to paint the price bars green if the current tic is higher than the previous bar's high (criteria #1), and continue to paint them green until the current tic is lower than the previous bar's low (criteria #2), at which point they would then be painted red. There would be no problem with this if the indicator was set to computeonclose. But what if the indicator was set to update on every tic and the criteria was met and then not met within the same bar?
For example, using one minute bars suppose bar #1 is green and bars #2 through #4 are also green because none of them have met the switching criteria. Then at 15 seconds into bar #5 the switching criteria is met, the default color is changed to red and bar #5 is now painted red. But at 30 seconds into bar #5 the current tic no longer meets the switching criteria, that is it is no longer lower than the previous low, BUT NOR IS IT HIGHER THAN THE PREVIOUS HIGH, so it has not met the criteria to switch the default color back to green. Assumming the price does not change from its thirty second price, then at the close of the 5th bar althougth the final tic is not lower than the previous low, the color of the bar has switched from green to red.
You may suggest I use BarState to identify a new bar and do a Computeonclose to reset the previous bar to its proper color. Sounds good ... but if instead of a one minute bar suppose we are dealing with a ten minute bar and, as I noted above the intrabar criteria match and then "not match" took place thirty seconds into the bar. In that case, for the remaining nine minutes and thirty seconds, that is until the next ten minute bar appears, a bar that should be painted green is painted red. And as Mel Brooks might say, "That ain't good."
So if the criteria is met intrabar, I'd like the color to switch. But if within the same bar conditions change and the crieria is no longer met then I would like it to switch back to the color of the previous bar. Any suggestions on how this could be done? Many thanks.
For example, using one minute bars suppose bar #1 is green and bars #2 through #4 are also green because none of them have met the switching criteria. Then at 15 seconds into bar #5 the switching criteria is met, the default color is changed to red and bar #5 is now painted red. But at 30 seconds into bar #5 the current tic no longer meets the switching criteria, that is it is no longer lower than the previous low, BUT NOR IS IT HIGHER THAN THE PREVIOUS HIGH, so it has not met the criteria to switch the default color back to green. Assumming the price does not change from its thirty second price, then at the close of the 5th bar althougth the final tic is not lower than the previous low, the color of the bar has switched from green to red.
You may suggest I use BarState to identify a new bar and do a Computeonclose to reset the previous bar to its proper color. Sounds good ... but if instead of a one minute bar suppose we are dealing with a ten minute bar and, as I noted above the intrabar criteria match and then "not match" took place thirty seconds into the bar. In that case, for the remaining nine minutes and thirty seconds, that is until the next ten minute bar appears, a bar that should be painted green is painted red. And as Mel Brooks might say, "That ain't good."
So if the criteria is met intrabar, I'd like the color to switch. But if within the same bar conditions change and the crieria is no longer met then I would like it to switch back to the color of the previous bar. Any suggestions on how this could be done? Many thanks.
Comment