Need help with EA

 

I am trying to adapt this EA to buy when Stochastic crosses above 50 and sell below.This part works however the trade only closes at stoploss or takeprofit levels.The OrderModify and OrderClose commands don't seem to work,can someone help explain why?

 

Maybe because the EA never looks at the open trade at position 0.

OrdersTotal() tells the number of open trades, and they are "indexed" by their "array position", i.e. from 0 to (OrdersTotal()-1).

 

Thanks for your reply ralph.ronnquist, yes I have seen that on other EA's I will try to copy from another and see how it goes. Cheers.

 
swagman1:
I am trying to adapt this EA to buy when Stochastic crosses above 50 and sell below.This part works however the trade only closes at stoploss or takeprofit levels.The OrderModify and OrderClose commands don't seem to work,can someone help explain why?

You may try to look at this thread https://www.mql5.com/en/forum/176153 (there are some good EAs based on Stichastic with forward testing results and discussion).