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 />

case 138:<br />

return(true);<br />

case 146:<br />

return(true);<br />

// Requotes<br />

// Trade context busy<br />

}<br />

}<br />

default:<br />

return(false);<br />

This function uses the switch operator. We are looking for a case label whose value matches the<br />

expression assigned to the switch operator (in this example, ErrorCode). If a matching case is<br />

found, the code after case is executed. If no case label matches, then the code after the default<br />

label is executed.<br />

When a case match is found, the switch block must be exited with a break or return operator. In<br />

this example, we are using the return operator to return a true/false value back to the calling<br />

function. The switch operator can be useful for evaluating a match for an integer constant, but its<br />

utility is rather limited.<br />

Here is how we use ErrorCheck() to conditionally retry an order placement:<br />

int Retries;<br />

int MaxRetries = 5;<br />

int Ticket;<br />

while(Ticket

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

Saved successfully!

Ooh no, something went wrong!