Thank you Mike,

And as a related tidbit, SetOption("PriceBoundChecking", False) doesn't always 
stop the Buy/Sell price from being altered.  To explicitly force AB to use the 
price you want, set the BuyPrice/SellPrice after you issue "Buy =" and "Sell 
=".  Of course you'll have to do all your own price checking to verify your 
price is legit...

Best Regards,
Michael



--- In [email protected], "Mike" <sfclimb...@...> wrote:
>
> False is a predefined constant set to the value 0.
> 
> By setting BuyPrice/SellPrice to False you are saying that you want to 
> purchase/sell the active symbol for $0.
> 
> If the Low of the bar for that symbol is greater than your BuyPrice, 
> AmiBroker will automatically alter the BuyPrice to be within the trading 
> range (using the Low, I think, in this case), unless you have disabled this 
> option via SetOption("PriceBoundChecking", False). Similarly your exit price 
> will be affected.
> 
> When not including these lines, AmiBroker will use whatever values you have 
> set in your AA Settings for entry/exit (e.g. Open). In the first case you 
> would effectively be entering/exiting at the Low. In the latter case you 
> would be entering/exiting at perhaps the Open, depending on your settings.
> 
> Naturally, this would affect the performance and the availability of funds 
> for later trades.
> 
> Mike
> 
> --- In [email protected], "michaels_musings" <michaels_musings@> 
> wrote:
> >
> > Hi All,
> > 
> > I ran across this while doing code exploration.  If I add
> > 
> > > BuyPrice = False;
> > > SellPrice = False;
> > 
> > to my .afl, then I get a different number of trades (and profits, etc.).  
> > With it I get 56 trades and without it I get 25 trades.
> > 
> > Obviously I'd like to know if it should be included/excluded to get proper 
> > results, but I'm more curious about the underlying reasons for the 
> > different results.  So I can understand what to do and not to do in the 
> > future.
> > 
> > My thanks to everyone on this list for being so knowledgeable and helpful,
> > Michael
> > 
> > 
> > Code in question :
> > ...
> > // Setup Arrays
> > Sell = False;  // Initialize "Sell" array....
> > Buy = False;  // Initialize "Buy" array....
> > BuyPrice = False;
> > SellPrice = False;
> > openPos = False; // No open positions to start with
> > lastLow = False; // Just initialize it
> > 
> > ...
> > // Start this Pig...
> > for ( i = 0; i < BarCount; i++ ) // Loop over all bars in the chart
> > {
> >   for ( j = 0; j < numBuyPoints; j++ ) // Loop over all Buy points
> >   {
> >     if ( openPos[j] ) // Have an open position, check to sell it
> >     {
> >       if ( Low[i] < myStopLosss[j] ) // Check for Stops First
> >       {
> >         Buy[stickBuySellAt] = True;
> >         BuyPrice[stickBuySellAt] = buyPrices[j];  // To override AA Trades 
> > tab, You must set Prices after Flagging
> >         stickBuySellAt = stickBuySellAt + 1;
> >         Sell[stickBuySellAt] = True;
> >         SellPrice[stickBuySellAt] = myStopLosss[j];
> >         stickBuySellAt = stickBuySellAt + 1;
> >         openPos[j] = False; // No longer have open position
> >         lastLow[j] = iif( Close[i] < SellPrice[i], Close[i], SellPrice[i] 
> > ); // ReSet lastLow[j] for Buy Check
> >         if ( writeLog == TRUE )
> > ...
> >
>


Reply via email to