PureBytes Links
Trading Reference Links
|
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/
|