Is it possible that there is an error in the code?
isInTrade = False;
priceatbuy = 0;
highsincebuy = 0;
exit = 0;
for ( i = 0; i < BarCount; i++ )
{
// if we are not in a trade and we have a buy signal then set the buy
price
if ( NOT isInTrade AND Buy[ i ] )
{
// now we are in a trade so set the buy price
isInTrade = True;
priceatbuy = BuyPrice[ i ];
}
// if we are in a trade then check to see if we hit the profit target
if ( isInTrade )
{
highsincebuy = Max( High[ i ], highsincebuy );
if( exit == 0 AND
High[ i ] >= ( 1 + FirstProfitTarget * 0.01 ) *
priceatbuy)
//reset isInTrade = False;
}
I get an error message...
Louis
2008/2/23, tuzo_wilson <[EMAIL PROTECTED]>:
>
> --- In [email protected], "Louis Pr�fontaine" <[EMAIL PROTECTED]>
> wrote:
>
> > Wouldn't it be possible to simply write
> >
> > if( Buy[ i ] )
> > {
> > priceatbuy = BuyPrice[ i ];
> > }
> >
> > instead of
> >
> >
> > if( priceatbuy == 0 AND Buy[ i ] )
> > {
> > priceatbuy = BuyPrice[ i ];
> > }
>
> The Buy array may have multiple buy signals (i.e. non zero entries) so you
> can't just use the Buy array.
>
> > if the priceatbuy value was already set to zero before the "for"
> command? I
> > mean: we already know that the only possible value of priceatbuy at this
> > point was zero, so why add the if (priceatbuy == 0... ? and not simply
> if
>
> That's not true. priceatbuy is set within the for loop. As its name
> indicates priceatbuy is used to hold the price when the buy signal was
> issued. Plus it is also being used to let you know if you are not in a
> trade (priceatbuy == 0) so from a logical point of view it is holding more
> than just the buy price information.
>
> You could rewrite it differently:
>
> isInTrade = False;
> priceatbuy = 0;
> highsincebuy = 0;
> exit = 0;
>
> for ( i = 0; i < BarCount; i++ )
> {
> // if we are not in a trade and we have a buy signal then set the buy
> price
> if ( NOT isInTrade AND Buy[ i ] )
> {
> // now we are in a trade so set the buy price
> isInTrade = True;
> priceatbuy = BuyPrice[ i ];
> }
>
> // if we are in a trade then check to see if we hit the profit target
> if ( isInTrade )
> {
> highsincebuy = Max( High[ i ], highsincebuy );
> if( exit == 0 AND
> High[ i ] >= ( 1 + FirstProfitTarget * 0.01 ) *
> priceatbuy)
>
> // reset isInTrade = False;
> }
> }
>
>
> The logic is is the same but maybe expressing it that way makes more sense
> to you?
>
>
> Tuzo
>
>
>