Approximation

Created at 23 Nov 2012, 12:23
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Uche's avatar

Uche

Joined 25.10.2012

Approximation
23 Nov 2012, 12:23


How do I round-up numbers in a code.

(Math.Round) obviously does not work.

 

Thanks


@Uche
Replies

admin
23 Nov 2012, 12:42

Can you type the syntax you are using and the desired outcome. Math.Round has a few overloads:

var a = Math.Round(7.45);
var b = Math.Round(7.45, 1);
var c = Math.Round(7.45, 2);
Print("{0},{1},{2}", a,b,c);

Output:
7, 7.4, 7.45


@admin

Uche
23 Nov 2012, 13:10

double _ml = Math.Round(calculation);

Error: The name 'Math' does not exist in the current context.


@Uche

admin
23 Nov 2012, 14:16

You need to add a reference to the System namespace:

using System;


When you add a new Indicator/Robot in the cAlgo platform it is included by default.

 


@admin