[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AFL Help Needed - X bar exit



PureBytes Links

Trading Reference Links

I'd like to exit a trade after x bars after entry.

malen = 25;
stddev = 2;
nday = 10;
buyprice = ref(bbandbot(low, malen, stddev), -1);
buy = cross(buyprice, low);
sell = barssince(buy) == nday;

The above code identifies the last, not the first, instance when the 
buy condition is met.

How can I express BarsSinceEntry in AFL?

Thank you in advance.