micke81:
im am really struggling with this code I have got it to place buy orders and it opens the correctnumber of trades. Then I want to close a single ticket if that ticket number has a profit of 1.20.Please helpVery much appreciated
In this section:
//+------------------------------------------------------------------+ //| Close all positions by opposite positions | //+------------------------------------------------------------------+
You're aware of the need to iterate through PositionsTotal() and then use PositionGetTicket(i) to select individual position for further processing.
However, you didn't do the same at the start, when u have these lines:
double PositionProfit=PositionGetDouble(POSITION_PROFIT); //position profit variable double PositionSwap=PositionGetDouble(POSITION_SWAP); //Position swap
So your ProfitThisCurrencyPair will always be zero, and no position will meet the closing criteria.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
im am really struggling with this code I have got it to place buy orders and it opens the correctnumber of trades. Then I want to close a single ticket if that ticket number has a profit of 1.20.Please helpVery much appreciated