Wont work in EA - page 2

 
phy:

Is the price which you are sending with the order correct?


Not sure, how do you tell. Sometimes there is a few trades in like 30 or so and eventually it gets an error. I am assuming that means that price has changed however, with the error 135 refresh rates it should clear it.

Also, the script works no matter what. It just doesn't work in the EA. Can We just call the script?

 
               result = OrderClose(OrderTicket(),OrderLots(),price,3,CLR_NONE);
               Print("Current Chart Price = "+Close[0]+" Order Closing Price = "+price);
               if(result != TRUE) {
                    Print("GOT AN ERROR ON THAT ONE");
 
phy:
               result = OrderClose(OrderTicket(),OrderLots(),price,3,CLR_NONE);
               Print("Current Chart Price = "+Close[0]+" Order Closing Price = "+price);
               if(result != TRUE) {
                    Print("GOT AN ERROR ON THAT ONE");

I will try it.  Looks to me like you are incrementing the close price and then adjusting the variable as well to match it?
 

Nope.

Just printing out what the chart says is the current bid and what you are sending to close the order.

This is an alternate way of builing a string to print:

string xxx = "there";

Print("Hello ", xxx);

Print("Hello "+xxx)

Should get the same printout.

 

Also, since you are apparently handling many orders, put a refresh in the loop.

   while (OrdersTotal() > 0) {
      // Loop through all orders and close them
      for (int i = (OrdersTotal() - 1); i >= 0; i--) {
 
         RefreshRates();
 
         if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
 
phy:

Also, since you are apparently handling many orders, put a refresh in the loop.

   while (OrdersTotal() > 0) {
      // Loop through all orders and close them
      for (int i = (OrdersTotal() - 1); i >= 0; i--) {
 
         RefreshRates();
 
         if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {

Ok, thanks I will try it.  Takes some time to create the positive effect and see if it works.  I only forward test.
Reason: