Rotational system - monthy switch considering no trading days

Hello Everyone,
My trading system assumes monthly switch of symbols as per:

Issue is that form:

m = Month();
PositionScore = IIf( m != Ref( m, -1 ), score, scoreNoRotate );

defines different dates for particular symbols, eg. for “XXX” 30th is the last day of the month, becose there was no trading on 31th. For “YYY” the last day is 31th becouse its different market.
This results in unwanted sell/buy signals.
Is there some solution to define the last day of the month with no dates discrepancy (other than manual date of quote change in Quote Editor)?

Go to Backtest settings - General - Pad and align all data to reference symbol

I am a beginner can you please tell
PositionScore = IIf( m != Ref( m, -1 ), score, scoreNoRotate );
In the above code month() will always be different from ref month () ,-1 or is there any time when both are equal .can you please elaborate

That will only work if you precede the PositionScore assignment with:

m = Month();

If you look up the Month() function in the help, it will answer your question.