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

Re: [amibroker] Removing Excess Signal, II



PureBytes Links

Trading Reference Links


Hi,
 
Indeed Dimitris presented very elegant solution to 
the problem of selling
after predetermined number of bars.
It is short and does not require 
scripting.
 
The shortest version is as follows:
 
buy = cross( macd(), signal() ); // or any other 
buy signal
sell = ref( buy, -5 ); // sell after 5 
bars
buy = exrem( buy, sell ); // this statement 
effectively clears unneccessary signals 
sell = exrem( sell, buy ); // so it works like a 
script-based formula but it's a lot faster
 
The funny thing is that ExRem function was 
designed exactly for that purpose,
but I went to the scripting side ;-)
Well, sometimes, the answer is simply 
too obvious :-) 
 
Best regards,Tomasz Janeczko===============AmiBroker - the 
comprehensive share manager.<A 
href="">http://www.amibroker.com
<BLOCKQUOTE 
>
----- Original Message ----- 
<DIV 
>From: 
Dimitris 
Tsokakis 
To: <A title=amibroker@xxxxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Friday, August 10, 2001 7:35 
PM
Subject: [amibroker] Removing Excess 
Signal, II

Dear Jon,
Thank you for explanation.
As I see, in your example, buy-sell are pairs with a 5-day 
distance.If you overcome one buy, you will overcome the respective sell 
also.
This is quite strange for me, from the trading point of 
view.
Anyway, it is quite tempty and here is my point of 
view:
(I just change 5 to 13, to have the series you describe, 
based
on a real example).
 
In graph "DETECTION BUY-SELL" from A to C we have 
your
B-B-S-B-S-S combination.
Below you see removal based on AFL function<FONT 
size=2> and the script removal.
The solution is the same, point to point, and perhapsit is 
the
same thing.
 
/*AFL FORMULA*/
 <FONT 
size=2>BUYD=cross(stochd(),30);SELLD=-ref(buyd,-13);e2=exrem(BUYD,SELLD);graph1=e2;graph1style=2;graph1barcolor=5;e1=-ref(e2,-13);graph0=e1;GRAPH0STYLE=2;
/*SCRIPT FORMULA*/
EnableScript("VBScript");buy = 
cross(stochd(),30);<%N = 13 buy = AFL( "buy" )sell= 
AFL("buy") barssincebuy = -1for i = 0 to UBound( buy )  sell( 
i ) = 0   if barssincebuy = -1  then    if 
buy( i ) = 1 then      barssincebuy = 
0   end if  else   barssincebuy = 
barssincebuy + 1   if barssincebuy = N  
then       sell( i ) = 
1       barssincebuy = -1   
end if  end if
next
AFL("sell") = sell
%>
buy = exrem( buy, sell );
<FONT 
size=2>graph0=sell;GRAPH0STYLE=2;graph1=buy;graph1style=2;graph1barcolor=5;
 
Take a look.
 
Dimitris Tsokakis
 
P. S. Sorry for changing the happy condition
Close == HHV( close, 250 ); 
I am in a 23 months bearish market and I should wait 
for
years to meet such a condition.
Thank you for the example.Your use of 
Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service.