Account.Balance.ToString() not working

Created at 13 Dec 2013, 20:03
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!
UV

uvx_01

Joined 13.12.2013

Account.Balance.ToString() not working
13 Dec 2013, 20:03


Hi,

I added plenty of Print(...) in my robot for the debug purposes.
The prints help me to monitor the robots operation. 

What I noticed that the Account.Balance.ToString() and Account.Equity.ToString() don't work.

Code for example:

protected override void OnTick()
{	...
	...
   if(......)
   {
       Print("Account.Balance before the trade is ", Account.Balance.ToString());
       Print("Account.Equity before the trade is ", Account.Equity.ToString());
  }
	...
        ...
}		

What I get in the prints is only:

13/12/2013 17:18:18.501 | Account.Balance before the trade is 
13/12/2013 17:18:18.501 | Account.Equity before the trade is 

As you see, no value is shown.

I am using a demo account. Not sure if it matters. 

Can anyone explain what is wrong?

Thanks

UVX

 

 

 

 


@uvx_01
Replies

Cerunnos
13 Dec 2013, 20:20

You have to add {0}

Print("Account.Balance before the trade is {0} ", Account.Balance);

 


@Cerunnos

uvx_01
13 Dec 2013, 20:23

This is a different approach. I will switch to it.

But the first one should work as well. 

The Account.Balance id double, which definitely has the ToString() method. 


@uvx_01

uvx_01
13 Dec 2013, 20:24

Sorry - typo:

Should be

"The Account.Balance IS double, which definitely has the ToString() method" 


@uvx_01

Cerunnos
13 Dec 2013, 20:29

Both should work with method print(): Account.Balance or Account.Balance.ToString()

 


@Cerunnos

Cerunnos
13 Dec 2013, 21:44

Thanks ;-)


@Cerunnos

uvx_01
13 Dec 2013, 21:47

Just tested again.

Print("Account.Balance before the trade is {0} ", Account.Balance);

is showing the numbers, while the 

Print("Account.Balance before the trade is ", Account.Balance.ToString());

isn't. 


@uvx_01

Hyperloop
13 Dec 2013, 23:31

RE:

uvx_01 said:

Just tested again.

Print("Account.Balance before the trade is {0} ", Account.Balance);

is showing the numbers, while the 

Print("Account.Balance before the trade is ", Account.Balance.ToString());

isn't. 

Of course the second wouldn't. 

Print("Account.Balance before the trade is " + Account.Balance.ToString());

This would though.


@Hyperloop

uvx_01
13 Dec 2013, 23:35

I just realized how stupid my question was.

I was pretty tired when I wrote this line of code :)

It should have been:

Print("Account.Balance before the trade is " + Account.Balance.ToString());

or 

string msg = "Account.Balance before the trade is " +  Account.Balance.ToString();
Print(msg);

 

LOL


@uvx_01

Hyperloop
13 Dec 2013, 23:35

Reason your code isn't working isn't because of the To.String(), it's because you're use of string concatenation is incorrect.


@Hyperloop