Hello, on a 5 minute chart I want to inspect the high, low, 1st open, last close for the last three candles and draw that as a separate panel indicator on the 5 minute chart.
Then the next 5 minute period and so on.
(That is, a rolling 15 minute bar on a 5 minute chart. Conventionally 15m bars are only :00, :15, :30, :45.)
So for the 3 candle ‘triplet’ the data generated is the max price high, min low across the three candles, the opening price at the start of the 15 minute ‘triplet’ and the closing price at the end of the ‘triplet’.
I’ve attached my code so far – it works and gives an exact representation of PRICE candles generated in this way, :00, :15, :30, :45 candles match exactly the corresponding 15 minute chart data.
My problem is: I do not get the correct result when I try to adjust my code for Heiken-Ashi output: it doesn’t match anything if I cross reference the 15m HA chart.
Can anyone suggest code that takes my triplet data and draws the Heiken-Ashi candle version?
Thank you very much
// Uses the 5m bars over the last 15m period to create a 15m bar EACH 5 MINUES
// Each price point:
TripletLow = Lowest[3](Low)
TripletHigh = Highest[3](High)
TripletOpen = Open[2]
TripletClose = Close
// Draw Bars
if TripletClose > TripletOpen then
DrawCandle(TripletOpen, TripletHigh, TripletLow, TripletClose) Coloured (0, 200, 0) // Green candle
else
DrawCandle(TripletOpen, TripletHigh, TripletLow, TripletClose) Coloured (200, 0, 0) // Red candle
endif
Return
JSParticipant
Senior
Here’s the conversion of the “triplets” to Heikin Ashi…
// Uses the 5m bars over the last 15m period to create a 15m bar EACH 5 MINUTES
// Basis triplet-data
TripletLow = Lowest[3](Low)
TripletHigh = Highest[3](High)
TripletOpen = Open[2]
TripletClose = Close
// Heikin-Ashi calculation
HAClose = (TripletOpen + TripletHigh + TripletLow + TripletClose) / 4
HAOpen = (TripletOpen + TripletClose) / 2 // Initialisation
HAOpen = (HAOpen + HAClose) / 2
HAHigh = Max(TripletHigh,Max(HAOpen, HAClose))
HALow = Min(TripletLow,Min(HAOpen, HAClose))
// Plotting HA-candles
if HAClose > HAOpen then
DrawCandle(HAOpen, HAHigh, HALow, HAClose) Coloured (0, 200, 0) // Groene HA candle
else
DrawCandle(HAOpen, HAHigh, HALow, HAClose) Coloured (200, 0, 0) // Rode HA candle
endif
Return