PureBytes Links
Trading Reference Links
|
Hello
Welcome any suggestions, as I am really only getting into this, and could do
with some suggestions on how to improve coding, and also alternative or
better ways of doing things.
To program a stop, which takes into consideration where the open next bar
would defintely leap frog a stop, I put this together this, from an example
from the user guide,
Buy = DayOfWeek()==1;
BuyPrice = Open;
priceatbuy=0;
stop=10;
for( i = 0; i < BarCount; i++ )
{
if( priceatbuy == 0 && Buy[ i ] )
priceatbuy = BuyPrice[ i ];
if( priceatbuy > 0 && Low[ i ] < (priceatbuy - stop) )
{
Sell[ i ] = 1;
SellPrice[ i ] = Min(SellPrice[ i ],(priceatbuy - stop));
priceatbuy = 0;
}
else
Sell[ i ] = 0;
}
Buy = ExRem(Buy,Sell);
It works, however I find I need to include the Buy = ExRem(Buy,Sell);
statement, else some funny things happen when exit and buy signals are
triggered on the same day. (Single bar trade is enabled on the backtester
settings).
Any thoughts on this, particularly to the one mentioned above, or otherwise
? I am sure there are some out there frowning at the code, and can see
improvements.
Thanks
Kind regards
Dave
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.5/645 - Release Date: 1/22/2007 4:10 PM
|