close one position and open an opposite position at the same time

 

I am trying to create code that will close one position and open the opposite position (ie close long and open short or vice versa) on the same technical signal. I can get a position to open if no other position is open and i can get it to close if a position is already open. I cannot get the ea to open a position then close it and then subsequently open the opposing position.


Any suggestions??


THanks

 
Look for function OrderCloseBy()
 
Here is the scripts I use NOTE: open them in the editor after you have installed them so you can set your tp and so on there is directions in each code.
Files:
scripts.zip  24 kb
 
doctort wrote >>

I am trying to create code that will close one position and open the opposite position (ie close long and open short or vice versa) on the same technical signal. I can get a position to open if no other position is open and i can get it to close if a position is already open. I cannot get the ea to open a position then close it and then subsequently open the opposing position.

Any suggestions??

THanks

try "OrderCloseBy()", this should work

 
Roger:
Look for function OrderCloseBy()

thanks!!

Reason: