#define MAGICMA 20050610

 

what does it means


#define MAGICMA 20050610


what kind of variable is MAGICMA ?? and why it is defined for value 20050610


I found this in the EA named Moviing Average

//+------------------------------------------------------------------+
//|                                               Moving Average.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#define MAGICMA  20050610

extern double Lots               = 0.1;
extern double MaximumRisk        = 0.02;
extern double DecreaseFactor     = 3;
extern double MovingPeriod       = 12;
extern double MovingShift        = 6;
 
Dario:

what does it means


#define MAGICMA 20050610


what kind of variable is MAGICMA ?? and why it is defined for value 20050610


I found this in the EA named Moviing Average


MAGICMA is the value for an identifer you can put in OrderSend to identiy your Order later ....

you als can say f.e. extern int MAGICMA=20050610 if you like to change sometimes in EA

Also is an integer and you can give numbers what you like/need. 20050610 is only an example or the idea from the author..

 
ok, then MAGICMA is a reserved word. It is correct?
 
Dario:
ok, then MAGICMA is a reserved word. It is correct?


No, not reserverd, you can call however you want .. MagicN, myMagicNumber, MN,.....

https://docs.mql4.com/basis/preprosessor/constant

You only need to find your Orders which are was opened with this Magic Number ... if (OrderMagicNumber()==myMagicNumber) do Something ...

 

Thank you

but then, in my modest opinion, it would have been better to call this variable OrderNumber.. less confusing.

 
Dario:

Thank you

but then, in my modest opinion, it would have been better to call this variable OrderNumber.. less confusing.


welcome :-)

like this is defined in Ordersend:

magic - Order magic number. May be used as user defined identifier.

if its good for you to call your variable Ordernumber .. why not?!
 

OrderSend give you the brokers order number, that is what you need to modify orders.

MagicNumber is not used by the broker, it allows you to differentiate orders by this EA vs all other orders.

The following code will find any open orders on the current chart by the current EA, ignoring all others. OrderTicket() returns the order number for the modification.

    for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber() == magic.number              // my magic number
    &&  OrderSymbol()      == Symbol() ){               // and symbol
        ...
        OrderModify(OrderTicket(), ...

#define MAGICMA 20050610

is not a good idea, as it doesn't allow the same EA to be placed on the same pair but two different time frames, and it doesn't allow changing the number incase of conflict with other EAs. Magic number should be an extern int.

 
Dario:

Thank you

but then, in my modest opinion, it would have been better to call this variable OrderNumber.. less confusing.

Replace  less  with more . . .   OrderNumber != Magic number   . . .  in the same way that  . . .   Seat number  !=  Flight number
 
OrderNumber would be easy to confuse with ticket number.
Reason: