Buy does not depend on the BuyPrice.  If Buy is True and the BuyPrice you set 
is below the Low, then AB sets the BuyPrice at the Low.  See 
"PriceBoundChecking" in Help.

Assuming you are sending a limit buy at the BuyPrice to your broker for a trade 
tomorrow:
.
.
.
BuyPrice = Close - ATR(10) * 0.5;// == limit buy price for tomorrow's trade
Buy = Cond1 AND Cond2 AND Cond3 AND Cond4 AND High >= Ref( BuyPrice, - 1 );
BuyPrice = Max( Open, Ref( BuyPrice, - 1 ) );

It would be clearer written:
LimitPrice = Close - ATR(10) * 0.5;
Buy = Cond1 AND Cond2 AND Cond3 AND Cond4 AND High >= Ref( LimitPrice, - 1 );
BuyPrice = Max( Open, Ref( LimitPrice, - 1 ) );



Regards,

Joe

--- In [email protected], "Siva" <sivsr...@...> wrote:
>
> My AFL basically buys when MA(20)starts trending up. The system should buy 
> only when my buyprice is hit.
> var1 = MA( Close, 20 );
> Cond1 = Ref( var1, -4 ) < Ref( var1, -5 ) ;
> Cond2 = Ref( var1, -3 ) < Ref( var1, -4 );
> Cond3 = Ref( var1, -2 ) > Ref( var1, -3 ) ;
> Cond4 = Ref( var1, -1 ) > Ref( var1, -2 );
> BuyPrice = Ref( Close, -1 ) - ( ATR(10) * 0.5 ) ;
> Buy = Cond1 AND Cond2 AND Cond3 AND Cond4 ;
> 
> But when I back test the above formula, it buys at bar low even when my 
> buyprice is not hit. How to avoid it buying at bar low? Thanks in advance.
>


Reply via email to