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

Re: [amibroker] Re: Low Array



PureBytes Links

Trading Reference Links

you could define your sellprice inside the loop:
 
 
if( priceatbuy > 0 && Low[ i ] < priceatbuy - 1) 

Sell[ i ] = 1; 
SellPrice[ i ] = priceatbuy[ i ]  - 1;



 
2007/7/12, mac_bosh <mac@xxxxxxxxxxx>:

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@xxx> 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.
>




--
Regards __._,_.___

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





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___