Anyway to output text?

Created at 23 Jul 2013, 20:13
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!
panupat's avatar

panupat

Joined 19.07.2013

Anyway to output text?
23 Jul 2013, 20:13


For testing purposes, is there a way to print or do Console.Write() just to check what is going on?


@panupat
Replies

kricka
24 Jul 2013, 08:09

Hi panupat,

what you can do is to print it to the log.

Within an if statement it could look like this.

if (  Account.Equity >= variable  )

 Print("Your own text {0}", Account.Equity );

This will print the account equity standing if the if statement. is true, to the log.

 

There is another way, by checking the info on screen by using ChartObjects.DrawText

ChartObjects.DrawText("Your own text", "Your own text"  Account.Equity, StaticPosition.TopRight, Colors.Red );

After the testing is done, one can remove the "Print" and "ChartObjects.DrawText" from the code. Its a fast way to get to know if the coding is done right.

There is alot of info on both the Print and the ChartObjects.DrawText in the reference API section.

 

 

 


        


@kricka

panupat
24 Jul 2013, 14:54

Thanks! I'm going to try that right away :)

 

About the log file, do the print command save to log file automatically, or is there an addition set of command for log files?


@panupat

kricka
24 Jul 2013, 17:45

RE:
panupat said:

Thanks! I'm going to try that right away :)

 

About the log file, do the print command save to log file automatically, or is there an addition set of command for log files?

It prints automatically to the log. The Log is located at the bottom of the platorm with the Positions, Orders, History and then the Log tab.


@kricka

algoforce
26 Jul 2013, 09:36

 double width = top - bottom; 

 

Print("Function#1: Width of Bands", width );

In the Log, I do not get the width printed. It is missing. 

 

in MQL i would use

 

 

Print(" My Band", DoubleToStr(width,5) );

 

to convert the double to string for printing. 

 

What do I use for calgo? 

 

I would like to print the band width ( double ) to my log onBar

 

 

 

 


@algoforce

cAlgo_Fanatic
26 Jul 2013, 11:41

Correct syntax includes:

1. Print("Function#1: Width of Bands {0}", width); // no need to convert to string in order to print

 

2. Print("Function#1: Width of Bands " + width.ToString("0.00000")); // Convert to string and concatenate strings. Format the output string to have 5 decimals

 

/api/internals/algo/print-75f5

 

@cAlgo_Fanatic