Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

N-Root Formula for Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:

This function calculates the n-root of a number or array.

Indicator / Formula

Copy & Paste Friendly
//------------------------------------------------------------------------------
//
//  This function calculates the n-root of a number or array.
//
//------------------------------------------------------------------------------

/*_______________________________________________________________________________________ 

  SYNTAX:
         nRoot(index,number)
  
  PURPOSE:
          This function calculates the n-root of a number or array.
          The n-root of a negative number returns a zero value. 
  
  HOW TO USE:
          Copy this file in your "include" directory or append it to another file
          that You use as "functions database".

  EXAMPLE:
          1. if you want to calculate the square-root of 100, you can use
             indifferently:

             Square_root = Sqrt(100);
             or
             n_Root = nRoot(2,100);

          2. if you want to calculate the cube-root of 100 or whatever:

             n_Root = nRoot(3,100);
             n_Root = nRoot(10,100);
             n_Root = nRoot(-2,Close);

  ______________________________________________________________________________________  
                                                                                        */

Function nRoot(index,number)
{    
    cond_r = index == 0 or number == 0 or number < 0;
    If_True = 0;
    If_False = (Exp ( (1 / index) * Log(number)));
    result = iif(cond_r, If_True, If_False);
    
    Return result;
}

0 comments

Leave Comment

Please login here to leave a comment.

Back