For one parameter I would like to use Monthly data.
If the Close of an index(^OMX) is below the 12 monthly simple moving average, I would not take the trade.
First of all please use code tags.
This is not your first day and not your first post on this forum.
I don't understand this ignorance.
(BTW another important one here).
As for your code lines... you check a compressed array against an uncompressed array in this line
var5 = IIf(MAOMX < FOREIGN("^OMX","Close"),1,0);
Instead it should be
var5 = IIf(MAOMX < MAOMX1,1,0);
If you want to use var5 later then you should not forget about expanding it (e.g if instead you want to check MAOMX against shorter time frame's ^OMX symbol's price).