PositionClose() does'nt work

 

Hi.

I want to Close a Position by PositionClose(Symbol(),4).

i Define as Below:
#include <Trade\Trade.mqh>
CTrade CT;
CT.PositionClose(Symbol(),4);

although compile has no error,  unfortunaltely PositionClose does'nt close open positions.



 
mohsen bahrami:

Hi.

I want to Close a Position by PositionClose(Symbol(),4).

i Define as Below:
#include <Trade\Trade.mqh>
CTrade CT;
CT.PositionClose(Symbol(),4);

although compile has no error,  unfortunaltely PositionClose does'nt close open positions.



You might consider doing error checking for any and all trade transactions using CTrade methods.

What do CT.ResultRetcode() and CT.ResultComment() say?

 
mohsen bahrami:

Hi.

I want to Close a Position by PositionClose(Symbol(),4).

i Define as Below:
#include <Trade\Trade.mqh>
CTrade CT;
CT.PositionClose(Symbol(),4);

although compile has no error,  unfortunaltely PositionClose does'nt close open positions.




You must have hedging account. Use RequestDeal() to get the ticket number of previous position, after opening the order. Then use that ticket number in your positionclose. Do not positionclose with symbol only.
 
ajola:

You must have hedging account. Use RequestDeal() to get the ticket number of previous position, after opening the order. Then use that ticket number in your positionclose. Do not positionclose with symbol only.

thanks

Reason: