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

[amibroker] Re: array processing vs loop processing



PureBytes Links

Trading Reference Links

Hi,

You should not be calling array based functions from within a loop.

The first argument to PlotShapes is an array. PlotShapes will take that array and plot the indicated shape on a bar by bar basis. By calling that within a loop, you are plotting all bars at every bar, using the same shape value at each bar for every bar (that's a mouthful, but reread it a few times and hopefully it will become more clear).

If you want to build up your own array for when a shape should be drawn, change your looping code to populate the array, then call PlotShapes once after the loop, passing in your array as the first argument.

e.g.
my_array = 0;
for( i = 0; i < BarCount; i++ )
{
  if( ...some true condition... )
  {  
    my_array[i] = shapeDownTriangle;
  }
  else
  {
    my_array[i] = shapeNone;
  } 
}
PlotShapes(my_array, ...);

Better still would be to use array math to produce the contents of my_array and skip the loop entirely.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "schnitt_tt" <schnitt_tt@xxx> wrote:
>
> Hi,
> 
> the follow code in Array processing shows a red down triangle if a gap
> appears.
> 
> it_gap     = GapDown();
> PlotShapes( IIf( it_gap,  shapeDownTriangle , shapeNone ), colorRed );
> 
> I tried to do this with loop processing:
> 
> it_gap     = GapDown();
> for( i = 1; i < BarCount; i++ )
> {
>       if( it_gap[i] == True )
>     {
>        PlotShapes(   shapeDownTriangle , colorGreen );
>      }
>      else
>      {
>         PlotShapes(   shapeNone , colorRed );
>      }
> }
> 
> any Idea why this doesn`t show the patterns ... ?
> Are their any Functions that I can`t use while looping ??
> 
> thx for answering
>




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

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

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/