I am a beginner , What conditional must use magic number? How to use magic number?
//Setting up the Magic Number
input ulong Magic_Number = 1234567890; //Magic Number
int OnInit()
{
trade.SetExpertMagicNumber(Magic_Number);
return(INIT_SUCCEEDED);
}
//Getting Position Magic Number so that EA only alters/close positions it opened.
for(int i=PositionsTotal()-1; i>=0; i--)
{
ulong Position_Magic_Number = PositionGetInteger(POSITION_MAGIC);
if(Position_Magic_Number == Magic_Number)
{
//Actions for positions that only the EA has opened
}
}
MagicNumber: "Magic" Identifier of the Order - the article (MT4)
陳柏昌:
I am a beginner , What conditional must use magic number? How to use magic number?
I am a beginner , What conditional must use magic number? How to use magic number?
Magic number is a number for 1 EA, to define the oders of that EA!
If you use a few EAs on 1 platform, you have to define the different magic number for each EA!
陳柏昌:
I am a beginner , What conditional must use magic number? How to use magic number?
Magic Number comparison is the way to go. you should use
Order Comment comparison only if your EA actually writes different
comments for different trading situations and you wanna have it to have
different actions for such cases.I am a beginner , What conditional must use magic number? How to use magic number?
Good luck !
陳柏昌: What conditional must use magic number? How to use magic number?
Using OrdersTotal directly and/or no Magic number filtering on your
OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual
trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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