Can i determine a condition on two time frame? Need help

hi expert.

I try coding this condition for many time but it not work. :tired_face::sob:

Condition 1: RSI(14) in weekly >= 50 // in weekly
Condition 2: EMA(5) > EMA(20) // in daily

buy = Condition 1 and Condition 2;

my code:

_SECTION_BEGIN("Price");
Plot(Close,"Price",colorYellow, styleBar);

_SECTION_END();

_SECTION_BEGIN("Up/Down inweekly");

tfw = inWeekly;
TimeFrameSet( tfw );
rsw = RSI(14);

Swing_up = RSI(14)>=50 ;
Swing_down = RSI(14)<=50 ;

TimeFrameRestore(); // restore time frame to original

expandmode = expandLast;

rsw = TimeFrameExpand( rsw, tfw, expandmode );

Plot( 1.5, "Ribbon",IIf( TimeFrameExpand(Swing_up , inWeekly), colorBrightGreen,
IIf( TimeFrameExpand(swing_down, inWeekly), colorRed, 0 )), styleOwnScale|styleArea|styleNoLabel, -1.5, 80 );

GfxSelectFont("Tahoma", Status("Pxheight")/40 );
GfxSetTextColor(colorWhite);
GfxTextOut( "Zoning: "+Name(), Status("Pxwidth")/5.5, Status("Pxheight")/1.11 );

Title = "\n"+EncodeColor(colorYellow)+"Rsi Weekly="+ WriteVal(Rsw ,format= 5.2)+

_SECTION_END();

//================= BUY & SELL ===============================
_SECTION_BEGIN("Buy & Sell");

Plot(EMA(Close,5),"EMA5",colorGreen,style=styleThick);
Plot(EMA(Close,20),"EMA20",colorRed,style=styleThick);

Buycondition1 = RSI(14) >=50; // inweekly
Buycondition2 = EMA(C,5) > EMA(C,20); // indaily

Sellcondition1 = RSI(14) <=50; // inweekly
Sellcondition2 = EMA(C,5) < EMA(C,20); // indaily

Buy = Buycondition1 AND Buycondition2;
Sell = Sellcondition1 AND Sellcondition2;

Buy = ExRem( Buy, Sell );

Sell = ExRem( Sell, Buy );

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone), colorYellow, 0, Low, Offset=-15);
PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone), colorYellow, 0, Low, Offset=-28);

PlotShapes(IIf(Sell, shapeDownArrow,shapeNone), colorYellow, 0, High, Offset=-15);
PlotShapes(IIf(Sell, shapeSmallCircle,shapeNone), colorWhite, 0, High, Offset= 28);

_SECTION_END();

Untitled