PureBytes Links
Trading Reference Links
|
Hello,Ok, I've been playing aroundwith
this for about half a day and I am getting frustrated ! So I thought I'd
throw it out to you AFL geniuses.Here's what I'm trying to
code.Entry:- based on certain buy conditions (called Buyconditions
in my AFL)- hold buy conditions to be true for "x" days (after which, abuy
should not occur, even if the buy conditions are still true)- buy price
should be "y" more than the high of the day the buy signal occurred (i.e. High +
y)Exit:- sell at the close if "z" days have passed OR sell if the
price goes below the low of the day before buy signal occurred, i.e. Ref(L,
-1)Here's my AFL so far but it doesn't seem to do what I'm trying to
do. Any help would be GREATLY appreciated.Buy =
Buyconditions;Buy = Hold (Buy, x);BuyPrice =
ValueWhen(Buy, High) + y;Sellcond1 = Ref(Buy,-z); // sell after z
daysSellcond2 = L <= ValueWhen(Buy, Ref(L,-1)); // sell ifprice
goes below the low of the day before the buy signal occurred
Sell = Sellcond1 OR
Sellcond2;SellPrice= IIf(Sellcond1, C, ValueWhen(Buy,
Ref(L,-1))); // If z days have passed, sell at the close. If price
has dropped below the low, sell at that
low./////////////////
|