Let's say I only want to use a higher timeframe on my chart to determine some kind of previous trend, using the ALREADY CLOSED bars of the higher timeframe (to mitigate repainting). The live prices can bounce up and down on the current lower timeframe all it wants, but I want the higher timeframe's data to be lagging by 1 bar, so that there's no repainting. Would that look something like this?
I create 2 variables calledand, and if their average values are greater than .5, color the bars blue, otherwise orange. In the bottom line, I am referencing the plus1AggTrend from 5 bars ago re: there being 5 x 1-min bars in 1 x 5-min bar. Is this correct? I initially thought that I could referenceinstead of, however the previous few bars repaint colours, so thinking either 5 or 6 is necessary to prevent that.
input currentTimeFrame = AggregationPeriod.Min; input plus1AggPeriod = AggregationPeriod.Five_Min; input TrendPeriods = 6; def currentTFOpen = open(period = currentTimeFrame); def currentTFHigh = high(period = currentTimeFrame); def currentTFLow = low(period = currentTimeFrame); def currentTFClose = close(period = currentTimeFrame); def currentTFHighestHigh = highest(currentTFHigh, trendPeriods); def currentTFLowestLow = lowest(currentTFLow, trendPeriods); def currentTFTrend = (currentTFClose - currentTFLowestLow) / (currentTFHighestHigh - currentTFLowestLow); def plus1AggOpen = open(period = plus1AggPeriod); def plus1AggHigh = high(period = plus1AggPeriod); def plus1AggLow = low(period = plus1AggPeriod); def plus1AggClose = close(period = plus1AggPeriod); def plus1AggHighestHigh = highest(plus1AggHigh, trendPeriods); def plus1AggLowestLow = lowest(plus1AggLow, trendPeriods); def plus1AggTrend = (plus1AggClose - plus1AggLowestLow) / (plus1AggHighestHigh - plus1AggLowestLow); AssignPriceColor(if((currentTFTrend + plus1AggTrend) / 2) > .5 then color.blue else color.orange);
I create 2 variables called
Last edited by a moderator: