I don't quite understand what you mean by 'iterates through a bar'. Given that 
there is only a single set of values (O/H/L/C) there is nothing to iterate 
through.

However, it is valid to have conditional logic in the assignment, yes. Though, 
your syntax usage is incorrect. See below for correction.

PositonSize = iif(L<limitprice2, -20, -10);
BuyPrice = iif(L<limitprice2, (limitprice1+limitprice2)/2,limitprice1);

Mike

--- In [email protected], "jmdeacon" <jmdea...@...> wrote:
>
> Can the position size vary as the program iterates through a bar?  For 
> instance can I write
> 
> iif(L<limitprice2, positionsize = -20, positionsize = -10);
> iif(L<limitprice2, buyprice = (limitprice1+limitprice2)/2,limitprice1);
> 
> John
> 
> --- In [email protected], "Mike" <sfclimbers@> wrote:
> >
> > If you want to do what you are proposing, you don't need CBT.
> > 
> > Whenever you recognize a "scalein" condition, just set the BuyPrice to the 
> > average of buyprice1 and buyprice2, and the position size to double the 
> > usual size. The backtester exits all positions (initial and scaled in) at a 
> > single Sell signal, so that is effectively what is happening anyway.
> > 
> > Mike
> > 
> > --- In [email protected], "jmdeacon" <jmdeacon@> wrote:
> > >
> > > What I want would not need intraday data.  The way I would want ti code 
> > > with OHLC is something like this:
> > > 
> > > limitprice1 = (ref(c,-1)*0.99);
> > > limitprice2 = (ref(c,-1)*0.98);
> > > 
> > > buyprice1 = min(O,limitprice1);
> > > buyprice2 = min(O,limitprice2);
> > > 
> > > Buy would occur if L < limitprice1.
> > > Scalein would occur if L <limitprice2.
> > > 
> > > If the low is less than the limitprice1, I would enter the position.  If 
> > > the low is less than the limitprice2, then I would scalein.  If the open 
> > > is below both prices then I would enter a double position at the price of 
> > > the open.
> > > 
> > > I already have this coded to work on seperate bars, but many times, the 
> > > pullback occurs on the same bar and I would like to backtest that 
> > > occuring on the day of the initial purchase.
> > > 
> > > So, the question is, is there some kind of CBT coding that would allow me 
> > > to test what I want to test.
> > > 
> > > Thanks,
> > > 
> > > John
> > > --- In [email protected], "Mike" <sfclimbers@> wrote:
> > > >
> > > > Hi
> > > > 
> > > > You can't do that. All you know is open/high/low/close. You don't know 
> > > > what happened in between.
> > > > 
> > > > Consider these two scenarios:
> > > > 
> > > > Open, gentle steady decline in price down to -2%.
> > > > Open, next trade after the open is a 2% drop.
> > > > 
> > > > Now, would you still want both an initial buy and a scale in for both 
> > > > scenarios? How would you know if half the position was bought at -1% 
> > > > and the other half at -2% (first scenario) vs. all bought at -2% 
> > > > (second scenario).
> > > > 
> > > > If you want intraday trades, you need intraday data.
> > > > 
> > > > Mike
> > > > 
> > > > --- In [email protected], "jmdeacon" <jmdeacon@> wrote:
> > > > >
> > > > > Is it possible to scale in on the same bar?  To make it clear, lets 
> > > > > say I am using EOD data and I want enter a position as the price 
> > > > > pulls back.  XYZ starts the day at $10 and I want to buy if it loses 
> > > > > 1% and scalein to double to position if it loses another 1%.  Is 
> > > > > there a way to code for that to occur on the same bar assuming XYZ 
> > > > > traded below $9.80 on the bar in question?  I know how to do it with 
> > > > > Scalein when it occurs on seperate bars?
> > > > > 
> > > > > Thanks,
> > > > > 
> > > > > John
> > > > >
> > > >
> > >
> >
>


Reply via email to