Re: [amibroker] How to handle logical situations?

 

1) When referring previous 15th bar, then bar numbers less than 15 will have Null values and show error.

So, do we use nz() in that case?

​If necessary but it is not always necessary. Nz() will replace Null with zeros.​

 


2) divisor as 0:

​​
Trend_Time_R2_S = 
​​
(nom_S / denom_S ) ^ 2;

Error: Warning 505: Divisiot by Zero. Divisor array at [21] is equal to zero.

What is the best way to fix it?


​Trend_Time = iif( isnull(denom_s), NULL, ​
(nom_S / denom_S ) ^ 2);


​If ​you do not want the Trend_time array to have NULL, 0, or any fixed (hardcoded) value, then:

​Trend_Time = iif( isnull(denom_s), NULL, ​
(nom_S / denom_S ) ^ 2);
​Trend_Time = iif( isnull(Trend_Time), ref(Trend_time, -1), Trend_Time);​ // or any thing you wanna calculate and replace the null with. 
 


3) Calculating market cap ROC within a vertical selector range:

​​
Period_Selected = EndValue( BarIndex()    )  - Nz(BeginValue( BarIndex() ));
Market_Cap_ROC_S = ROC(Market_Cap_S , Nz(abs(Period_Selected)));

Error: Error 52, Invalid argument value for ROC() function. Range must be greater than zero (and not Null).

Period_Selected = EndValue( BarIndex()    )  - Nz(BeginValue( BarIndex() ));
if( isnull( Period_Selected ) ) Period_Selected = 1;
Market_Cap_ROC_S = ROC(Market_Cap_S , Nz(abs(Period_Selected)));

 





__._,_.___

Posted by: =?UTF-8?Q?Jo=C3=A3o_Fl=C3=A1vio_Machado_Derzi?= <joaoderzi@gmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

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


.

__,_._,___


EmoticonEmoticon