Switching auto trading state problem with Expert Advisor

 
Hello guys, I need some help getting my EA to work properly. The thing is, he can modify positions, but only if I assign the EA to my symbol chart with autotrading ALREADY ENABLED. If I assign the EA to the chart while autotrading is disabled (disabled via the button) and attempt to modify position I get "cannot modify position due to autotrading disabled". If I enable autotrading later on, calls like CTrade.PositionModify() only responds with "CTrade::OrderSend: ... [auto trading disabled by client]". I also made sure that auto trading is allowed in Options/Experts tab. So what am I missing here? Thanks in advance!
 
nowayfra:
Hello guys, I need some help getting my EA to work properly. The thing is, he can modify positions, but only if I assign the EA to my symbol chart with autotrading ALREADY ENABLED. If I assign the EA to the chart while autotrading is disabled (disabled via the button) and attempt to modify position I get "cannot modify position due to autotrading disabled". If I enable autotrading later on, calls like CTrade.PositionModify() only responds with "CTrade::OrderSend: ... [auto trading disabled by client]". I also made sure that auto trading is allowed in Options/Experts tab. So what am I missing here? Thanks in advance!
Long story, try to make it short
 
Short:

if button auto trading enabled -> EA start -> CTrade may modify positions -> OK

if button auto trading disabled -> EA start -> button auto trading enabled -> CTrade may NOT modify positions -> NOT OK

Any ideas why?
 
nowayfra:
Short:

if button auto trading enabled -> EA start -> CTrade may modify positions -> OK

if button auto trading disabled -> EA start -> button auto trading enabled -> CTrade may NOT modify positions -> NOT OK

Any ideas why?

I think that I am encountering the same behaviour today. Have you found a solution for this?

In my case is PositionClose() not working as I would expect. I get the error message "auto trading disabled by client", even though Buy() and Sell() work properly.

Reason: