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

[amibroker] Re: AFL help to understand my bug



PureBytes Links

Trading Reference Links

I really don't know what you are trying to do. I don't know why you 
are trying to use a loop. Loops are the last thing you should use in 
AFL if there is any way around them. Your logic is looking for 
instances where aire3 is between two numbers. It seems it is also 
looking for a value of 100 or 222. It will never get to 100 or 222. 
WMA / MA will be a very small number and you will need 4 decimal 
places to see the value at times. If you are trying to find the bar 
number where the statement is true then try the following formula. 
The last column shows the bar where the Croisement is 1. Also, it is 
always helpful to plot your results when debugging. Plots are 
included.

Barry

aire1 = WMA(C,150);
aire2 = MA(C,50);
aire3 = aire1 / aire2 ;

Croisement = 0 ;
Croisement = IIf(aire3 >= 0.95 AND aire3 <= 1.00, 1, IIf(aire3 == 
222, 2, 0));

Plot(aire1, "aire1", colorRed);
Plot(aire2, "aire2", colorGreen);
Plot(aire3, "aire3", colorBlack, styleOwnScale);

PlotShapes(IIf(Croisement == 1, shapeSmallCircle, 0), colorRed);
PlotShapes(IIf(Croisement == 2, shapeHollowSmallCircle, 0), 
colorGreen);

Filter =1;

AddColumn(aire1,"aire1",1.2);
AddColumn(aire2,"aire2",1.2);
AddColumn(aire3,"aire3",1.4); // value of wma / ma
AddColumn(Croisement,"croisement"); // 1 or 2 when statement is true, 
else 0
AddColumn(IIf(Croisement == 1, int(BarIndex()), 
False), "Croisement"); // shows the bar where true


--- In amibroker@xxxxxxxxxxxxxxx, "atlas190" <atlas190@xxx> wrote:
>
> Hello ,
> 
> I meet a bug when I spy the "Croisement" variable with the 
> spreadsheet "results"  (explorer) .
> The variable "croisement" should receive the value "100" sometimes 
> and not always the value "222" .
> 
> It's probably a beginner's bug ...
> 
> 
> aire1 = WMA(C,150);
> aire2 = MA(C,50);
> aire3 = aire1 / aire2 ;  
> recup =0;
> Croisement =0 ;
> 
> bi = BarIndex();
> 
> for(i=0; i < BarCount -1 ;i++)
> {
> 
> recup[i] = bi[i];
> 
> if (aire3[i] >= 0.95 AND aire3[i] <= 1.00) 
> 
> {
>  //Croisement == recup[i];
> Croisement == 100;   //I don't reach this line ?!
>                      // I am sure that sometimes aire3 has got a 
>                      // value beetwee 0.95 and 1 
> }
> else
> { 
> Croisement = 222;
> }
> 
> Filter =1;
> 
> //AddColumn(bi,"barindex");
> AddColumn(recup,"pour voir");
> AddColumn(aire1,"aire1",format = 1.2);
> AddColumn(aire2,"aire2",format = 1.2);
> AddColumn(aire3,"aire3",format = 1.2);
> AddColumn(Croisement,"croisement");
> //AddColumn(a,"valeur du croisement");
>



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

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

*********************
TO GET TECHNICAL 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/