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

Re: [amibroker] Re: Modulus Operator and PI



PureBytes Links

Trading Reference Links

Hi Dimitris,

For example if you want to generate a "1" every 8th bar
you can now write

impulse8 = ( cum(1) % 8 ) == 0;

This is useful when you try to simulate different periodicity from daily data:

close8 = ValueWhen( impulse8, close );
high8 = HighestSince( impulse8, high );
low8 = LowestSince( impulse8, low );

Best regards,
Tomasz Janeczko


----- Original Message -----
From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: 06 September, 2001 11:48
Subject: [amibroker] Re: Modulus Operator and PI


Dear Tomasz,
Thank you for detailed description of % operator.
How shall we use it? Any target in mind?
(I met somewhere equal remainders in periodic functions, detrending
and similar techniques, but nothing certain)
If there is any operation through %, please advise.
Best Regards
Dimitris Tsokakis
--- In amibroker@xxxx, "Tomasz Janeczko" <amibroker@xxxx> wrote:
> Hello,
>
> There is an error in the the description of % operator.
> In fact it uses internaly fmod() C-runtime library function for
> performing operations. It means that it does not round the numbers
> to nearest integers:
>
> The fmod runtime function (and x % y operator in AFL) calculates
the floating-point remainder f of x / y such that x = i * y + f,
where i is an integer, f has the same sign as x, and the absolute
value of f is less than the absolute value of y.
>
>
> Best regards,
> Tomasz Janeczko
> ===============
> AmiBroker - the comprehensive share manager.
> http://www.amibroker.com
>
> ----- Original Message -----
> From: Dimitris Tsokakis
> To: amibroker@xxxx
> Sent: Wednesday, September 05, 2001 8:17 PM
> Subject: [amibroker] Modulus Operator and PI
>
>
>
> Dear Tomasz,
> The new 3.70 Help is very well prepared again. Tutorials for new
items is the
> certainly the best way.
> I noticed something not so clear in
>
> Modulus operator
> A new operator (%) - modulus (or remainder) was added:
> result = number1 % number2
> The modulus, or remainder, operator divides number1 by number2
> (rounding floating-point numbers to integers) and returns only
the remainder as result.
>
> The plural "numbers" in the parenthesis may be translated that we
round
> number1 and number2, then we divide and then take the remainder.
> This would give 3.2%3.1==3%3==0, which is not the result of 3.2%
3.1.
> As I saw, the procedure is
> 3.2/3.1 gives 1.03
> 1.03 becomes 1 after rounding
> 3.2-3.1*1==0.1, which is the 3.2%3.1.
> I saw that the generic formula behind % is
> R1%R2==R1-R2*INT(R1/R2);
> for positive, negative, integers or non-integers.
> Is it O. K. ?
> Please confirm.
> Best regards
> Dimitris Tsokakis
> P. S. Please remember in some next edition to correct the typo in
> EXAMPLE The formula "atan( 1.00 )" returns PI/2
>
> It is our only source for PI in AFL.
> PI=4*atan(1);
>
>
> Yahoo! Groups Sponsor
> ADVERTISEMENT
>
> Start here...
>
> Height:
> 345678 ft 01234567891011in
>
> Weight:
> lbs. kg.
>
>
>
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.





Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/