Here it is Larry. Sorry I didn't check in with the group over the weekend,
thus the delay.

BuyCnd=some code to establish buy to use in loop;
SellCnd=some code to establish sell to use in loop;
ShortCnd=some code to establish short to use in loop;
CoverCnd=some code to establish cover to use in loop;

lpos=0; spos=0;
for( i = 26; i < BarCount; i++ )
{
  //Long side evaluation
  if(BuyCnd[i] AND lpos[i-1]==0) //original buy sig
  {
    Buy[i]=1;
    lpos[i]=1;
  }
  if(lpos[i-1]) //continue long
  {
    lpos[i]=1;
  }
  if(SellCnd[i] AND lpos[i] AND Buy[i-1]==0)
  {
    Sell[i]=1;
    lpos[i]=0;
  }
 //short side evaluation
  if(ShortCnd[i] AND spos[i-1]==0) //original short sig
  {
    Short[i]=1;
    spos[i]=1;
  }
  if(spos[i-1]) //continue short
  {
    spos[i]=1;
  }
  if(CoverCnd[i] AND spos[i] AND Short[i-1]==0)
  {
    Cover[i]=1;
    spos[i]=0;
  }
}


One note. The first bar becomes a buy and I don't know why. I set i to 26 to
start on barcount 26 rather than to 1 trying to avoid this. Doesn't have an
effect.

Hope the code helps you



On Sat, Nov 15, 2008 at 9:18 AM, onelkm <[EMAIL PROTECTED]> wrote:

>   Esteban
> Would you please post your code, I have the same issue and have not
> gotten a loop to work.
> Thanks
> Larry
> --- In [email protected] <amibroker%40yahoogroups.com>, "Esteban"
> <[EMAIL PROTECTED]> wrote:
> >
> > Thanks. I was able to model what I want using a For loop like you
> > suggested. It was easier than I thought it would be ... I was
> hesitant
> > to even try. The nice thing is that you can do all the array
> processing
> > you can before the loop, and then use the arrays in the loop. This
> kept
> > the loop simple and targeted to my specific problem.
> >
> > It still runs quite fast, but there's only one loop.
> >
> > --- In [email protected] <amibroker%40yahoogroups.com>, "Steve
> Davis" <_sdavis@> wrote:
> > >
> > > This kind of problem can be solved by writing a for loop and
> setting
> > > the buy/sell signals one bar at a time. You will have complete
> control
> > > over the signals, but it will run somewhat slower.
> > >
> > > -Steve
> >
>
> 
>

Reply via email to