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

Re: [amibroker] Re: Sell IF Today Open > Entry Price



PureBytes Links

Trading Reference Links

Hello,

ValueWhen reports last occurrence while it may not be
the bar when actual buying took place. Instead use this code:

Buy = O > Ref( 0, -1 ); 

priceatbuy=0; 
for( i = 0; i < BarCount; i++ ) 
{ 
     if( priceatbuy == 0 && Buy[ i ] ) 
     priceatbuy = BuyPrice[ i ]; 

     if( priceatbuy > 0 && Open[ i ] > priceatbuy ) 
     { 
       Sell[ i ] = 1; 
       SellPrice[ i ] = Open[ i ]; 
       priceatbuy = 0; 
     } 
     else 
       Sell[ i ] = 0; 
} 


Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "ami_trader" <ami_trader@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, February 18, 2005 7:02 PM
Subject: [amibroker] Re: Sell IF Today Open > Entry Price


> 
> 
> First of all, Thank you at all for the help.
> 
> This formula doesn't works.
> --------Formula 1----------
> Buy= Cross(O , Ref(O,-1));
> EntryPrice=ValueWhen(Buy,O);
> Sell=Cross(O , Ref(EntryPrice,-1));
> Buy=ExRem(Buy,Sell);
> Sell=ExRem(Sell,Buy);
> ---------------------------
> 
> 
> This formula instead seems to work but it is wrong:
> --------Formula 2--------------
> Buy= O > Ref(O,-1);
> EntryPrice=ValueWhen(Buy,O);
> Sell=O > Ref(EntryPrice,-1);
> Buy=ExRem(Buy,Sell);
> Sell=ExRem(Sell,Buy);
> ------------------------------
> 
> sell signal is wrong.
> 
> here is my simply test on AAPL 10 quotation 
> 
> 2/16/2005 88.15
> 2/15/2005 86.66
> 2/14/2005 82.73
> 2/11/2005 79.86
> 2/10/2005 78.72
> 2/9/2005  81.04
> 2/8/2005  79.07
> 2/7/2005  78.93
> 2/4/2005  77.87
> 2/3/2005  79.10
> 
> Long 2/3/2005  79.1   2/8/2005   79.07 --> *Wrong, ex price is < 
> entry price*
> Long 2/9/2005  81.04  2/14/2005  82.73
> Long 2/15/2005 86.66  2/16/2005 88.15 
> 
> Thank you in advance
> 
> ---
> Giuseppe
> 
> 
> 
> 
> 
> 
> Check AmiBroker web page at:
> http://www.amibroker.com/
> 
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/