Hello my friends,
Please help me.
I can get magic number for one position.
If I have two position, how can i get the magic for second position?
For example:
I have a position buy for EUR-USD
I can get the magic number for this position with this order:
Positiongetinteger(POSITION_MAGIC)
ok?
Now I open the new sell position for EUR_USD in the same symbol
And same timeframe.
how can I get the magic number for sell position?
In fact. I want get the magic number for second position.
But I don't know that how do it
Thanks alot of you
- How to create 2 magic numbers in 1 EA
- How to get total open positions with a magic number in mql5
- magic number for each position ?
You need to go through all positions in a loop. Example: loop through all positions and get the 'Magic' of each position.
[data folder]\MQL5\Experts\Examples\Moving Average\Moving Average.mq5
//+------------------------------------------------------------------+ //| Position select depending on netting or hedging | //+------------------------------------------------------------------+ bool SelectPosition() { bool res=false; //--- check position in Hedging mode if(ExtHedging) { uint total=PositionsTotal(); for(uint i=0; i<total; i++) { string position_symbol=PositionGetSymbol(i); if(_Symbol==position_symbol && MA_MAGIC==PositionGetInteger(POSITION_MAGIC)) { res=true; break; } } } //--- check position in Netting mode else { if(!PositionSelect(_Symbol)) return(false); else return(PositionGetInteger(POSITION_MAGIC)==MA_MAGIC); //---check Magic number } //--- result for Hedging mode return(res); }
Vladimir Karputov #:
Hello dear Vladimir.You need to go through all positions in a loop. Example: loop through all positions and get the 'Magic' of each position.
[data folder]\MQL5\Experts\Examples\Moving Average\Moving Average.mq5
Thank you from the bottom of my heart.
I tried hard and asked everyone, but no one answered.
Thanks alot for your answer

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