As far as AFL machine logic is concerned, the following is okay:
period=50;
//period is used in code for the next few lines
//then
//BuyPrice = x
x = 10;
//trying to use the BuyPrice to adjust the period
//for example,
y = IIf( X > 10, Ref(period,-10),period);
However, you need to describe your goal in words more precise for us to offer any good help.