Color change code help based on conditions

I am trying to achieve color change based on one condition and keeps like that until second condition happens

Once price cross above yesterday's high ribbon color is green until it breaks any other day Low then it turns Red and continues to red until any other day it crosses Yesterday High

But with my effort only days its crossed those levels its changing colors . Appreciate your time

yDayH = 	TimeFrameGetPrice("H", inDaily, -1);	  
yDayL = 	TimeFrameGetPrice("L", inDaily, -1);	  


dUptrend= C> yDayH      ;
ddntrend=      C < yDayL ;


Plot(yDayH, "Yesterday High ",colorGreen,styleDots|styleNoRescale|styleNoTitle|styleNoLabel,Null,Null, 0 ,0, 1);
Plot(yDayL, "Yesterday Low ",colorRed,styleDots|styleNoRescale|styleNoTitle|styleNoLabel,Null,Null, 0 ,0, 1);


Plot( 1.1, "DRibbon",IIf( dUptrend, colorGreen,  
 IIf( ddntrend, colorRed ,  colorYellow  )), styleOwnScale|styleArea , -11.5, 100,0, 2,1);




..

image

Use Flip() function

yDayH = TimeFrameGetPrice("H", inDaily, -1);	  
yDayL = TimeFrameGetPrice("L", inDaily, -1);	  

dUptrend = C > yDayH;
ddntrend = C < yDayL;

style = styleDots|styleNoRescale|styleNoTitle|styleNoLabel;
Plot( yDayH, "Yesterday High ", colorGreen, style, Null, Null, 0, 0, 1 );
Plot( yDayL, "Yesterday Low ", colorRed, style, Null, Null, 0, 0, 1 );

Uptrend = Flip( dUptrend, DDntrend);

riboncol = IIf( Uptrend, colorGreen, colorRed );
Plot( 1.1, "DRibbon", riboncol, styleOwnScale | styleArea , -11.5, 100, 0, 2, 1 );

Thanks a ton @fxshrat . This is the final output (Incase any one looking for ..)

// To visualize Hourly , Daily, Weekly, and Monthly  Trend 
 
 
tdayhH  = TimeFrameGetPrice("H", inHourly, -1);	
tdayhL = TimeFrameGetPrice("L", inHourly, -1);
 
yDayH = TimeFrameGetPrice("H", inDaily, -1);	  
yDayL = TimeFrameGetPrice("L", inDaily, -1);	
 
ywH = 	TimeFrameGetPrice("H", inWeekly, -1);	  
ywL = 	TimeFrameGetPrice("L", inWeekly, -1);
	
yMH = 	TimeFrameGetPrice("H", inMonthly, -1);	  
yML = 	TimeFrameGetPrice("L", inMonthly, -1);	  



hUptrend = C > tdayhH;
hdntrend = C < tdayhL;

dUptrend = C > yDayH;
ddntrend = C < yDayL;

WUptrend = C > ywH;
Wdntrend = C < ywL;

MUptrend = C > yMH;
Mdntrend = C < yML;


UptrendH = Flip( HUptrend, HDntrend);
UptrendD = Flip( DUptrend, Ddntrend);
UptrendW = Flip( WUptrend, WDntrend);
UptrendM = Flip( MUptrend, MDntrend);


styleR = styleOwnScale | styleArea |styleNoLabel|styleNoTitle ;


riboncodH = IIf( UptrendH, colorGreen, colorRed );
Plot( 1.1, "HRibbon", riboncodH, styleR , -20, 100, 0, 2, 1 );

riboncodD = IIf( UptrendD, colorGreen, colorRed );
Plot( 1.1, "DRibbon", riboncodD, styleR, -15, 100, 0, 2, 1 );
 
riboncodW = IIf( UptrendW, colorGreen, colorRed );
Plot( 1.1, "WRibbon", riboncodW, styleR , -10, 100, 0, 2, 1 );

riboncodM = IIf( UptrendM, colorGreen, colorRed );
Plot( 1.1, "MRibbon", riboncodM, styleR , -5, 100, 0, 2, 1 );


// Plotting Lines -- Daily ( Green    )-- Weekly ( Yellow) -- Monthly ( Red) 

styleP = styleDots|styleNoRescale|styleNoTitle|styleNoLabel;
 
Plot( yDayH, "Yesterday High ", colorGreen, styleP, Null, Null, 0, 0, 1 );
Plot( yDayL, "Yesterday Low ", colorGreen, styleP, Null, Null, 0, 0, 1 );

Plot( ywH, "Previous Week  High ", colorYellow, styleP, Null, Null, 0, 0, 2 );
Plot( ywL, "Previous Week Low ", colorYellow, styleP, Null, Null, 0, 0, 2 );

Plot( yMH, "Previous Month High ", colorRed, styleP, Null, Null, 0, 0, 3 );
Plot( yML, "Previous Month Low ", colorRed, styleP, Null, Null, 0, 0, 3 );

Plot( 20, "",   colorBlack  , styleArea|styleOwnScale|styleNoLabel, 1 ,100,0, 1,1 );

// Displaying text next to ribbons 
GfxTextOut( "Hourly  Trend " , status("Pxwidth")/1.1, Status("Pxheight")/1.25 );
GfxTextOut( "Daily Trend " , status("Pxwidth")/1.1, Status("Pxheight")/1.20 );
GfxTextOut( "Weekly Trend " , status("Pxwidth")/1.1, Status("Pxheight")/1.15 );
GfxTextOut( "Monthly Trend " , status("Pxwidth")/1.1, Status("Pxheight")/1.10 );





image