PureBytes Links
Trading Reference Links
|
Hello!
I've succeeded to solve this (thanks to Tomasz's code examples) the
following simple (but a bit ugly) way. I'm sure there is a nicer
solution...
intrade = IIF (buy, 1, IIF (sell, 0, -1));
/* If buy and sell signals happen at the same day, exit the trade,
i.e. pick the sell signal
!!! Need this 'CUM(buy)' because sell (obtained using cross() method)
is {EMPTY} at time of the first buy signal */
intrade = IIF (CUM (buy) > 1, IIF (intrade AND sell, 0, intrade),
intrade);
intrade = IIF (intrade == -1, ref (intrade, -1), intrade);
intrade = IIF (intrade == -1, ref (intrade, -1), intrade);
intrade = IIF (intrade == -1, ref (intrade, -1), intrade);
intrade = IIF (intrade == -1, ref (intrade, -1), intrade);
intrade = IIF (intrade == -1, ref (intrade, -1), intrade);
/*
....
!!! need the number of IIFs equal or more the maximum number between
the subsequent buy and sell signals...
*/
/* Do not change buy if want to add positions for each subsequent
buy signal
*/
/* !!! Need this 'CUM(buy)' because ref (intrade, -1) is undefined
for the first buy signal */
buy = IIF (CUM (buy) == 1, buy, ref (intrade, -1) < intrade);
sell = ref (intrade, -1) > intrade;
date() + " intrade: " + writeval (intrade) + "\n";
Thank you,
Dima.
--- In amibroker@xxxxxxxxxxx, rasnitsyn@xxxx wrote:
> Hello!
>
> Is it possible to get "clean", i.e. filter out repetative buy/sell
> signals in AFL?
>
> The following is an example of what I'm trying to achieve:
>
> buy : { 1, 0, 0, 0, 0, 0, 1, 1, 0 }
> sell: { 0, 0, 1, 0, 1, 1, 0, 0, 1 }
>
> I need to get the following vectors:
>
> realbuy: { 1, 0, 0, 0, 0, 0, 1, 0, 0}
> realsell:{ 0, 0, 1, 0, 0, 0, 0, 0, 1}
>
> Is it possible to od this in AFL?
>
> Thanks in advance,
> Dima.
|