Hi,

A couple of quick observations.

1. Don't use IIF inside the loop, use if.
2. Don't use Ref(Buy[i], -1) inside the loop, use Buy[i - 1].
3. If you find that you really must use a loop for your logic 
(usually can be done without a loop), you could probably just 
populate an array inside the loop and then call PlotShapes a single 
time after the loop has finished.

I haven't tested the following code, but try something along the 
following (though, again, you could probably do this without looping):

e.g.
for( i = 0; i < BarCount; i++ )
{
   if( inBuy==0 AND Buy[i] )
   {
     inBuy= 1;
     ValueAtBuy = C[i];
     Arrows[i] = 1;
     Stars[i] = (Buy[i - 1] > 0);
   }
}

PlotShapes(IIF(Arrows, shapeUpArrow, shapeNone), colorOrange, 0, L, -
15);
PlotShapes(IIF(Stars, shapeStar, shapeNone), colorOrange, 0, 
BuyPrice, -15);

Mike

--- In [email protected], "ozzyapeman" <[EMAIL PROTECTED]> wrote:
>
> Having trouble moving  PlotShapes inside a BarCount loop.
> 
> Outside the loop the following works fine:
> 
> PlotShapes(Buy * shapeUpArrow, colorOrange,0,L,-15);
> PlotShapes(IIf(Ref(Buy, -1), shapeStar, shapeNone), colorOrange, 0,
> BuyPrice, -15);
> 
> But for reasons to do with my trading system, I need to move the
> plotting inside a loop, like below (only pasting relevant sections).
> It's going crazy, plotting shapes everywhere. Obviously my syntax 
must
> be wrong. Any help much appreciated:
> 
> for( i = 0; i < BarCount; i++ )
> {
>      if( inBuy==0 AND Buy[i] )
>    {
>    inBuy= 1;
>    ValueAtBuy = C[i];
>    PlotShapes(Buy[i] * shapeUpArrow, colorOrange,0,L[i],-15);
>    PlotShapes(IIf(Ref(Buy[i], -1), shapeStar, shapeNone), 
colorOrange, 0,
> BuyPrice[i], -15);
>    }
> }
>


Reply via email to