Opening & Closing Orders?

 
I'm sure this is in the forums ad nauseam, but being new I must ask how does one code the opening or closing of an order assuming it means the condition of an "if statement"? I know about OrderSend() and OrderClose(), but how are they used? How is an order triggered and how is its closing triggered using those? Thanks.
 

the secret of "how to become a (good) programmer" is "try and error"

i dont know another way.

start with simple problems like adding 2 numbers and displaying them with i.e. "Comment()"

step by step ....

 
renner1984:
I'm sure this is in the forums ad nauseam, but being new I must ask how does one code the opening or closing of an order assuming it means the condition of an "if statement"? I know about OrderSend() and OrderClose(), but how are they used? How is an order triggered and how is its closing triggered using those? Thanks.

If you check the documentation you will see the following:


1. OrderClose() is a "bool".

This means that it returns a true or false (0 or 1) depending upon its success.

if (OrderClose(blah,blah)) : the following code block will be executed if the order close function returns success. It is shorthand for saying if (OrderClose(blah,blah) == true).


2. OrderSend() is an "int".

This means that it returns an integer - in this case the ticket number of the associated order if OrderSend is successful.

So in this case your conditional statement will check for a valid ticket number in order to ascertain whether the open send has worked.


CB

Reason: