Help!! Position Reverse problem

 

Hello, 


I have a very simple yet complex situation.

I simply want to reverse buy to sell or sell to buy.

I tried looking in the forum in the link below and got to the following lines of code on the last posting



Will this doit?

OrderClose(OrderTicket(),OrderLots(),Bid,2,Violet); // close position
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,1,0,Ask+TakeProfit*Point,"Reversed Signal",16384,0,Blue


I basically tried OrderClose followed by Ticket=Ordersend

Tried it within the same and different curly braces.

It didnt work in Real live trading but worked just fine in Demo

I got an error message when tried to do it in Real Live. 

I have been losing as my EA kept failing to reverse my position.  


I tried another method as well. 

I first close the open position, go to return(0) so tht the EA will start again and be ready to open the opposite position when it restart.

This still didnt work. 


Is there anyone out there who knows how the solution?

If you've used the code above and it worked, pls let me know as well. 

An advice as to help me point out the location of the problem would also be great.

 
MrReza :

Hello,

I have a very simple yet complex situation.

I simply want to reverse buy to sell or sell to buy.

I tried looking in the forum in the link below and got to the following lines of code on the last posting


Will this doit?

OrderClose(OrderTicket(),OrderLots(),Bid,2,Violet); // close position
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,1,0,Ask+TakeProfit*Point,"Reversed Signal",16384,0,Blue

I basically tried OrderClose followed by Ticket=Ordersend

Tried it within the same and different curly braces.

It didnt work in Real live trading but worked just fine in Demo

I got an error message when tried to do it in Real Live.

I have been losing as my EA kept failing to reverse my position.

I tried another method as well.

I first close the open position, go to return(0) so tht the EA will start again and be ready to open the opposite position when it restart.

This still didnt work.

Is there anyone out there who knows how the solution?

If you've used the code above and it worked, pls let me know as well.

An advice as to help me point out the location of the problem would also be great.

You cannot "reverse" orders - you can only close a long/short order and then take an opposing position. This could be automated if required.