5 is not divisible by 3, was: not Fetching higher timeframe heikenashi

I want to fetch 5-minute Heikin-Ashi OHLC values and display them on a 3-minute chart, but I'm having trouble. The 5-minute values are correct on a 1-minute chart, but they don't match when I switch to a 3-minute chart. I tried calculating the 5-minute Heikin-Ashi values using TIMEFRAMESET and TIMEFRAME RESTORE, then expanding them to a 1-minute chart, but it didn't work.

///////////////MULTITIMEFRAME HEIKENASHI CHECKING 19 07 2024
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
//Plot( C, "Close",colorDefault, styleNoTitle | styleCandle | GetPriceStyle() );
_SECTION_END();

colorBullish = ParamColor("Color for bullish candle (Close > Open)", colorRGB(255, 255, 255));
colorBearish = ParamColor("Color for bearish candle (Close < Open)", colorRGB(255, 0, 255));
timeframe = in5Minute;
TimeFrameSet(timeframe);
Close_5t=(open+high+low+close)/4;
Open_5t = AMA( Ref( Close_5t,  -1 ),  0.5 );
High_5t = Max( high,  Max( Close_5t,  Open_5t ) );
Low_5t = Min( Low,  Min( Close_5t,  Open_5t ) );
//color5 = IIf(Close_5t>Open_5t,colorGreen,colorRed);
close5t = Close;
TimeFrameRestore();
//opcl = (Open+Close+Low+High)/4;
//closeha1 = TimeFrameCompress(opcl,in5Minute,compressLast);
//closeexha1 = TimeFrameExpand(closeha1,in15Minute,expandLast);

Open5 = TimeFrameexpand(Open_5t,timeframe,expandFirst);
close5 = TimeFrameexpand(Close_5t,timeframe,expandFirst);
high5 = TimeFrameexpand(High_5t,timeframe,expandFirst);
low5 = TimeFrameexpand(Low_5t,timeframe,expandFirst);
//colo51 = TimeFrameexpand(color5,timeframe,expandFirst);

//opcl5 = TimeFrameexpand(opcl,timeframe,expandFirst);
//close5g = TimeFrameGetPrice("Close",timeframe);
Plot(close5,"close5",colorAqua);
Plot(Open5,"Open5",colorRed);
Plot(high5,"high5",colorYellow);
Plot(low5,"low5",colorGreen);
Haclose_1=(Open+High+Low+Close)/4;
HaOpen_1 = AMA( Ref( HaClose_1,  -1 ),  0.5 );
HaHigh_1= Max( High,  Max( HaClose_1,  HaOpen_1 ) );
HaLow_1 = Min( Low,  Min( HaClose_1,  HaOpen_1 ) );

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", HaOpen_1, HaHigh_1, HaLow_1, Haclose_1, SelectedValue( ROC( Haclose_1, 1 ) ) ));
PlotOHLC(HaOpen_1,HaHigh_1,HaLow_1,Haclose_1,"HEIKENASHI",color = IIf(Haclose_1>=HaOpen_1,colorbullish,colorbearish),styleNoTitle | styleCandle | GetPriceStyle() );

 //PlotShapes(IIf(Close>0,shapeUpArrow,shapeNone),colo51, 0,L, Offset=-20);

Moderator comment: I have fixed your post. Next time make sure you are using proper CODE TAGS for the formula

Is 5 divisible by 3, without reminder?
No.

You can't compress from 3 minute to 5 minute because it doesn't make any sense.

What you can do is to use 1-minute chart to display both 3-minute and 5-minute values.

Thank you for solving my problem sir.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.