[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: PlotShapes inside an array loop!



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> 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);
>    }
> }
>



------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/