magic number

 
can ea open everytrade with diffrent magic number?
 
Yes.
 
Hi, the magic number must be different for each EA, because the platform uses this number to recognize EA. Regards Greg
 
Marco vd Heijden:
Yes.

i mean to say can it open 10 trades withh diffrent magic numbers?

i have ea with fix magic number, how can i change it to send new magic number every time it opens a trade?

 
kinjal parekh :
can ea open everytrade with diffrent magic number?

Sure.

Here is an example of very simple code (This is just an example! Opening POSITIONS in OnInit is WRONG!)

//+------------------------------------------------------------------+
//|                                  Each deal has its own magic.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//--- include
#include <Trade\Trade.mqh>
//---
CTrade         m_trade;                      // object of CTrade class
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   int InpMagic=200;         // Magic number
   for(int i=InpMagic; i<InpMagic+5; i++)
     {
      m_trade.SetExpertMagicNumber(i);
      m_trade.Buy(0.01);
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+

and the result:


 
Vladimir Karputov:

Sure.

Here is an example of very simple code (This is just an example! Opening POSITIONS in OnInit is WRONG!)

and the result:


i have attach my ea , can you please guide me with it ,that how can i modify in mql4.

Files:
 

That one uses magic numbers from the input parameters.

input int                     PA_Magic                         = 111;//Panel A Magic Number
input int                     PB_Magic                         = 111;//Panel B Magic Number
input int                     PC_Magic                         = 111;//Panel C Magic Number
 
kinjal parekh :

i have attach my ea , can you please guide me with it ,that how can i modify in mql4.

No. Sorry, I threw out the old language (MQL4) seven years ago.

 
Marco vd Heijden:

That one uses magic numbers from the input parameters.

ya and its fixed for trades,

i want too replace fix magic number to "new magic number everytime ea opens a new trade"

 

I don't understand why you would want that but you can use a simple counter that increments the magic number on every trade.

But it will completely and utterly derail your expert.

Files:
 
Marco vd Heijden:

I don't understand why you would want that but you can use a simple counter that increments the magic number on every trade.

But it will completely and utterly derail your expert.

how will it derail my expert? its a geniun quistion

Reason: