Mathematical Function to round “a” to the nearest whole number.
Syntax:
1 |
ROUND(a,digits) |
“digits” is optional. It is the number of digits after decimal point.
Example:
1 2 3 4 5 6 7 |
i1 = ROC[10](close) roundedROCvalue = ROUND(i1) RETURN i1,roundedROCvalue // i1=9.60 and roundedROCvalue=10 |
Il me semble que
roundedROCvalue = 10 pour il=9.60
C’est juste ! merci pour la correction !
Bonjour 🙂 Petite question:
ROUND(0.4) ça me donne 1 ou 0?
ça retournera 0 qui est le chiffre rond le plus proche. La version 11 de PRT intègre les instructions FLOOR et CEIL si besoin 😉
super merci !
Use this code to round down to half ordersizes and stay compatible with PRT 10.3 (no FLOOR or CEIL command!)
“Add PRT code” button not working?!
Well here is the code to round down to 0.5 multiples, e.g. when used within a money management loop to calculate ordersizes.
OrdersizeRaw = equity/FundsNeededPerPosition
OrdersizeRounded = round (OrdersizeRaw, 0) //rounded up or down!
OrdersizeDiff = OrdersizeRounded – OrdersizeRaw
If Ordersizediff >0 THEN // it was rounded up before
Ordersize = OrdersizeRounded-0.5
ELSIF Ordersizediff<0 THEN // it was rounded down before
Ordersize = OrdersizeRounded
ELSE
Ordersize = OrdersizeRounded
Endif