How to check previous day's MA1 crossing?

MA1_checking

As my uploaded *.png shows (if you can see it),
I want to check the previous day's MA1 crossing in an hourly chart,
where "MA1 crossing" means if bars in previous day cross over or under the MA1.

My problem is,
Oct 11 contains 16 hourly bar,
Oct 12 contains 21 hourly bar,
when I check the previous day's MA1 at Oct 12, it need to check 16 bars (Oct 11),
when I check the previous day's MA1 at Oct 13, it need to check 21 bars (Oct 12),
so I feel hard to deal with my requirement,
and my coding scenario (pseudo code) as below:

MA1 = MA( C, 25 ); // firstly, get MA1
MA1_crossing_in_previous_day = IIf( xxxx, 1, 0 ); // check bar crossing in previous day

Could anyone help me? Thank you! :smiley:

Please note: My "previous day" actually means "yesterday".

Use Cross and ValueWhen functions http://www.amibroker.com/f?cross and http://www.amibroker.com/f?valuewhen. Also use search to find existing examples how to use ValueWhen there are literally dozens of them on this forum already.

Thanks for reminding. :smiley: