Did you lookup the meaning of code 10009? —
10009
TRADE_RETCODE_DONE
Request completed
- www.mql5.com
bool selected=PositionSelect(_Symbol);
By the way, is this a "netting" account or a "hedging" account?
I hope it is a "netting" account, because if it is for a "hedging" account, then using this method of selecting a position is not ideal.
For the "netting" interpretation of positions (ACCOUNT_MARGIN_MODE_RETAIL_NETTING and ACCOUNT_MARGIN_MODE_EXCHANGE), only one position can exist for a symbol at any moment of time. This position is a result of one or more deals. Do not confuse positions with valid pending orders, which are also displayed on the Trading tab of the Toolbox window.
If individual positions are allowed (ACCOUNT_MARGIN_MODE_RETAIL_HEDGING), multiple positions can be open for one symbol. In this case, PositionSelect will select a position with the lowest ticket.
By the way, is this a "netting" account or a "hedging" account?
I hope it is a "netting" account, because if it is for a "hedging" account, then using this method of selecting a position is not ideal.
For the "netting" interpretation of positions (ACCOUNT_MARGIN_MODE_RETAIL_NETTING and ACCOUNT_MARGIN_MODE_EXCHANGE), only one position can exist for a symbol at any moment of time. This position is a result of one or more deals. Do not confuse positions with valid pending orders, which are also displayed on the Trading tab of the Toolbox window.
If individual positions are allowed (ACCOUNT_MARGIN_MODE_RETAIL_HEDGING), multiple positions can be open for one symbol. In this case, PositionSelect will select a position with the lowest ticket.
Its Netting, and its the Journal log in the strategy tester.
- All in all it gives no further information, but when i breakpoint the function i got like 10 decimals after my SL, which should only be two i guess?
Tried rounding it 10 different ways it always gives the same 10 decimals.
Something is wrong here ...
if(!trade.PositionModify(1234567, pricess, takeprofit))
What is 1234567 supposed to be?
You should be using the position's ticket ...
ulong pos_ticket = PositionGetInteger( POSITION_TICKET ); if( !trade.PositionModify( pos_ticket, pricess, takeprofit ) )
Something is wrong here ...
What is 1234567 supposed to be?
You should be using the position's ticket ...
Because there's only ever one trade going at a time, i give it a forced ticket/Magic number, this has nothing to do with the issue, from my understanding.
- Already tried the solution you just gave but with no result, since its just giving the exact same output a generated ticket thats getting called in the PositionModify, exact same as my "1234567".
The ticket is always 1234567.
if(Position_Count == 1){ if(Bid >= oneup){ CheckTradeAndMoveBreakEven(); } }
This is the code running the function above.
Basicly just sees if bid goes over a certain price, if it does it runs the function - which works because the breakpoints in the function gets hit when the condition occurs
Because there's only ever one trade going at a time, i give it a forced ticket/Magic number, this has nothing to do with the issue, from my understanding.
- Already tried the solution you just gave but with no result, since its just giving the exact same output a generated ticket thats getting called in the PositionModify, exact same as my "1234567".
The ticket is always 1234567.
This is the code running the function above.
Basicly just sees if bid goes over a certain price, if it does it runs the function - which works because the breakpoints in the function gets hit when the condition occurs
You can't force a ticket number. The ticket number is generated by the trade server, not you nor your code.
A magic number is not a ticket number. They are two different things.
Use the proper ticket number as I have shown.
Also, make sure to check the Stops Level and Freeze Level before moving stops — The checks a trading robot must pass before publication in the Market
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
This is for MQL5.
I've made an EA and everything is working but my Position Modify, its all the right values but it simply doesn't go through.
Here's some pictures to show that the values are correct.
I'm simply trying to breakeven my trade when an area on the chart is hit -> when the area is hit i call the function
But it gives me the errorcode above. "method failed" but still gives me a success code? - the Symbol Market Watch Stop loss is at = 0 so i should be able to do whatever with the stoploss, but it doesn't let me do anything.
- I also tried using OrderModify, exact same result.
Some help would be really appreciated, i searched the forum for same error but didnt find anything really.