Hi all,

this is my first post, i hope i can do this right...

I would really appreciate if you guys can help me on my problem...

**Background:**

a. i work with 1 minute data and on M1 chart

b. i need to plot some lines in M1Chart with calculation/logic from M5 Chart

c. the calculation/logic is to find PriceLevel and its BarIndex

Codes:

Below are some of the code logic that works in any timeframe (for example lets say M1 chart)

```
cond_bar1 = (bCond OR sCond);
cond_bar2 = ValueWhen(cond_bar1, BarIndex());
final_CondBar = cond_bar1 AND (cond_bar2 < BarCount-1);
for(i = 1; i <= 3; i++)
{
Bar_BI = LastValue(ValueWhen(final_CondBar, BarIndex(), i));
Bar_Price = LastValue(ValueWhen(final_CondBar, C, i));
Cond_Line= LineArray(Bar_BI[i], Bar_Price[i], BarCount-1, Bar_Price[i]);
Plot(Cond_Line,"Cond"+i, colorGold, styleLine|styleNoRescale|styleNoTitle);
PlotText("I" + i + "// " + Bar_Price[i], BarCount+2, Bar_Price[i],colorGold);
}
```

**Problem:**

Now my problem is to plot the same logic; Taking True condition from M5 data, and plot it into the M1 chart.

I'm not really sure if this is indexing problem in my logic or my code just can't find the True condition of final_CondBar in Compressed M5,... Somehow the M5 price level and barindex (compressed & expanded) plot in M1 chart, is not same with those in M5 Chart (normal uncompressed).

I already tried 2 approaches from Amibroker references:

a. TimeFrameSet() and TimeFrameRestore()

```
TimeFrameSet(in5Minute);
cond_bar1 = (bCond OR sCond);
cond_bar2 = ValueWhen(cond_bar1, BarIndex());
final_CondBar = cond_bar1 AND (cond_bar2 < BarCount-1);
for(i = 1; i <= 3; i++)
{
Bar_BI = LastValue(ValueWhen(final_CondBar, BarIndex(), i));
Bar_Price = LastValue(ValueWhen(final_CondBar, C, i));
Cond_Line= LineArray(Bar_BI[i], Bar_Price[i], BarCount-1, Bar_Price[i]);
TimeFrameRestore();
Plot(TimeFrameExpand(Cond_Line,in5Minute),"Cond"+i, colorGold, styleLine|styleNoRescale|styleNoTitle);
PlotText("I" + i + "// " + Bar_Price[i], BarCount+2, Bar_Price[i],colorGold);
}
```

b. TimeFrameCompress() & TimeFrameExpand()

```
cond_bar1 = (bCond OR sCond);
cond_bar2 = ValueWhen(cond_bar1, BarIndex());
final_CondBar = cond_bar1 AND (cond_bar2 < BarCount-1);
final_CondBar5 = TimeFrameCompress(final_CondBar, in5Minute);
for(i = 1; i <= 3; i++)
{
Bar_BI = LastValue(ValueWhen(final_CondBar5, BarIndex(), i));
Bar_Price = LastValue(ValueWhen(final_CondBar5, C, i));
Cond_Line= LineArray(Bar_BI[i], Bar_Price[i], BarCount-1, Bar_Price[i]);
TimeFrameRestore();
Plot(TimeFrameExpand(Cond_Line,in5Minute),"Cond"+i, colorGold, styleLine|styleNoRescale|styleNoTitle);
PlotText("I" + i + "// " + Bar_Price[i], BarCount+2, Bar_Price[i],colorGold);
}
```

These 2 approaches are not showing correct pricelevel & barindex.

Please help.. or guide me to the right direction in working with this problem.

Thanks in advance.