25.10.2016 Views

Expert Advisor Programming by Andrew R. Young

Expert Advisor Programming by Andrew R. Young

Expert Advisor Programming by Andrew R. Young

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

EXPERT ADVISOR PROGRAMMING<br />

Chapter 8<br />

Tips and Tricks<br />

In this chapter, we will cover additional features that may be useful in your expert advisors.<br />

Escape Characters<br />

If you want to add quotes or a backslash character to a string constant, you'll need to escape the<br />

character using a backslash (\). For example, if you need to insert a double quote, the escape<br />

character will be \". For a single quote, the escape character is \'. For a backslash, use two<br />

backslashes as the escape character: \\<br />

string EscQuotes = "This string has \"escaped double quotes\"";<br />

// Output: This string has "escaped double quotes"<br />

string EscQuote = "This string has \'escaped single quotes\'";<br />

// Output: This string has 'escaped single quotes'<br />

string EscSlash = "This string has an escaped backslash \\";<br />

// Output: This string has an escaped backslash \<br />

If you need a string to span multiple lines, use the escape character \n to add a newline:<br />

string NewLine = "This string has \n a newline";<br />

// Output: This string has<br />

a newline<br />

Using Chart Comments<br />

You can print text in the top left hand corner of the chart using the Comment() function. This can be<br />

used to print status information, indicator settings or any other information you may find useful.<br />

One method for displaying chart comments is to declare several string variables and concatenate<br />

them together with newline characters. One string can be used to display settings, another to display<br />

information messages or order status, etc. The concatenated string will be passed to the Comment()<br />

function. Place the Comment() function at the end of the start() function to update the chart<br />

comment:<br />

122

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!