You can certainly do that, provided you write line 6 correctly:
1
xx=dOpen(1)-dOpen(2)
unfortunately testing XX at line 8 makes no sense, since it will ALWAYS be true; whether positive or negative there will always be (well… it’s not 100% granted, but it’s quite rare otherwise) a difference in price between the opening of two different days!
Sure you can do that, you can add any other codes in a loop, even another loop. Coding with loops is the main subject of the advanced programming course.