The thing is when the bar value is 52 or 10.. at that movement it should close the bar and go next .. bar creation.. the repainted is called when that bar vanishes when price comes back.. like 5500 .. two red bars as it came down from 5510 and bar lenght is 5... But what happens is those 2 bars vanishes from the chart when price goes back to 5510.. so that is the main problem..