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

[amibroker] Re: Basisc - Array vs Loop Processing



PureBytes Links

Trading Reference Links

You can't set the shapes in a loop. Shapes work off arrays. In the loop you are building the arrays that shapes need later. Calculate the data in the loop, if you really need to, and then use shapes outside the loop and your problem should go away. 

Acutally since the gap functions are arrays you do not need to put the logic in a loop. The only time you need a loop is when the data you are using is not in array form and you need to put it into an array to make it compatible with AFL. Most of the stuff you need to do in Amy can be done without loops. I came from a C++ environment and tried to use arrays. Big mistake. The code becomes much more complicated and is usually unnecessary. You can put all sorts of stuff in a simple logic statement and forget loops. For instance you could use this in a buy statement and without an IIF statement:

buy = aMACD > ref(aMACD, -1) and CCI(5) > 50 and C > ref(C, -2);

You can do that in a loop but not on one line. AFL is very efficient once you learn how to use it. An that AIN'T easy. It took me over a year to unlearn C++ coding and learn AFL.

Also in  your code below you do not need the IIF in the plotshapes. 
All you need to do is 

PlotShapes(GapUp() * shapeUpArrow, colorGreen);

You would only need the IIF if the results of the calculation is not boolean. GapUp() and GapDown() return boolean. Also remember that anything not 0 is true.

Also in code you do not need to say if(GapIp() == TRUE) you can simply say if(GapUp()) for the true case or if(!GapUp()) for the false case. Ditto with GapDown().

Hope that helps,
Barry

--- In amibroker@xxxxxxxxxxxxxxx, "schnitt_tt" <schnitt_tt@xxx> wrote:
>
> Hi,
> 
> just make my first steps in AFL, to get a "Debugging" functionality I
> try to put a shape on a chart if a condition is met. (Software
> development is givin`.
> 
> target: if "GAP DOWN" appears show a shape.
> 
>   "ARRAY"-Version
> 
> it_gap     = GapDown();
> 
> PlotShapes( IIf( it_gap,  shapeDownTriangle , shapeNone ), colorRed );
> PlotShapes( IIf( GapUp(),  shapeUpTriangle , shapeNone ), colorGreen);
> 
> does function !!!!  [:)]
> 
>   "LOOP"-Version:
> 
> it_gap     = GapDown();
> for( i = 1; i < BarCount; i++ )
> {
> 
>     if( it_gap[i] == True )
>     {
>       PlotShapes(   shapeUpTriangle , colorGreen );
>      }
>      else
>      {
>        PlotShapes(   shapeNone , colorRed );
>      }
> }
> 
> ->result is .... on every single bar a shape is drawn.
> 
> here is how I think the "LOOP-Version" is function ...
> 
> 1) the array it_gap is filled via function "GAP_DOWN()"
> 
>      in it_gap is for every bar that has a gap the "number" 1.
> 
> 2) FOR loop
> 
>       doesn`T work ... I thought in the For loop I look at every single
> day. if it is true (1) a green shape should appear,
>      otherwise no shape will be drawn  ..
> 
> 
> 
> thx for your reply schnitt ...
>




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

**** 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/