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

[amibroker] Re: Low Array



PureBytes Links

Trading Reference Links

Hi

I realised that my code will sell me out on the same day I buy the 
stock, since Low is smaller than Close (which is my BuyPrice) for 
that day. I checked my settings and figured out that since I did not 
allow exit on the same day, this exit is not reported. 

Thanks.

--- In amibroker@xxxxxxxxxxxxxxx, "mac_bosh" <mac@xxx> wrote:
>
> Hi,
> Nothing appears to be wrong with your code, But, and I stand to be
> corrected, ensure that you have the correct settings in here:
> Menu->Analysis->Automatic Analysis->Setting->Trades
> 
> Bosh
> --- In amibroker@xxxxxxxxxxxxxxx, "jl2012_30" <jl2012_30@> wrote:
> >
> > I'm totally new to Amibroker and am very lost.
> > 
> > I'm trying to write a code that implements a stop loss if the 
stock 
> > falls $1 below my buy price.
> > 
> > I tried the following code but it does not work (I don't get stop 
out 
> > at all). 
> > 
> > -----------------------
> > Sell = 0;
> > 
> > priceatbuy = 0;
> > for( i = 0; i < BarCount; i++ ) 
> > { 
> >      if( priceatbuy == 0 && Buy[ i ] ) 
> >      priceatbuy = BuyPrice[ i ]; 
> > 
> >      if( priceatbuy > 0 && Low[ i ] < priceatbuy - 1) 
> >      { 
> >        Sell[ i ] = 1; 
> >        SellPrice[ i ] = Close[i]; 
> >        priceatbuy = 0; 
> >      } 
> >      else 
> >        Sell[ i ] = 0; 
> > } 
> > 
> > -------------------------
> > 
> > However, if I change the statement 
> > 
> > if( priceatbuy > 0 && Low[ i ] < priceatbuy - 1)  to
> > if( priceatbuy > 0 && Close[ i ] < priceatbuy - 1) 
> > 
> > the code will stop me out correctly based on the Close array.
> > 
> > What is wrong with my code above? Any help is definitely very 
much 
> > appreciated.
> >
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/