PureBytes Links
Trading Reference Links
|
Hi,
the accurate way to exit on n bars is
BUy= something;
sell= ref(exremspan(buy, n),-n);
for applystop I am not sure, but when we write
ApplyStop(0,2,atr(3),1);
it seems that applystop use the difference between H-atr(3)
so in the case OF
ApplyStop(0,2,Ref(low,-1),1); the stoplloss would be H-ref(Low,-1)
it is not what you want.
or again applystop is not obvious.
stephane
> Hello,
>
> Ok, I've been playing around with 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, a buy
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 days
> Sellcond2 = L <= ValueWhen(Buy, Ref(L,-1)); // sell if price 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.
>
> /////////////////
|