MAGIC NUMBER - page 2

 
SSSNO1:

Yes I get what you are saying strategy tester, my question is can I have same EA  not different EAs, attached 5 times with unique magic numbers as above so that it is treated differently so that whatever orders opened by the EA on each chart gets treated differently for equity management EA on the other account to recognize them differently and perform its action on those group accordingly?


Yes
 
If your TP was simply points, this can be a unique input for each EA.

If your EA closes positions based on percentage of equity then each EA should have its own such percentage input.
 

Yes I am going to be testing that on accounts but you are aware that I am using a copier for the job, wouldnt it matter, will it still recognize the magic numbers, that is the Equity management EA?

As you said TP by points would be a unique input for the EA but that is when the Equity sentry recognizes USDCAD as USDCAD and control its equity only and close accordingly only USDCAD order, live or pending orders.

I tried to test it before with the magic numbers but it just closed all the orders and was not symbol specific.

If you can give feedback about the Swiss army EA, I will be obliged.

Thank you

 
SSSNO1:

Yes I am going to be testing that on accounts but you are aware that I am using a copier for the job, wouldnt it matter, will it still recognize the magic numbers, that is the Equity management EA?

As you said TP by points would be a unique input for the EA but that is when the Equity sentry recognizes USDCAD as USDCAD and control its equity only and close accordingly only USDCAD order, live or pending orders.

I tried to test it before with the magic numbers but it just closed all the orders and was not symbol specific.

If you can give feedback about the Swiss army EA, I will be obliged.

Thank you

I have not used MT4 in a while. Once I install it on my PC I will post some demo code
 
//+------------------------------------------------------------------+
//|                                                       sample.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
input long _magic_number = 0;
input double _tp_percent = 0.05;//Implying 5%
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(60);
      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
         for(int i=OrdersTotal()-1;i>=0;i--)
           {
               if(OrderSelect(i,MODE_TRADES))
                 {
                     if(OrderMagicNumber() != _magic_number)
                       {
                           continue;
                       }
                       
                     if(OrderProfit() > 0.0)
                       {
                           if(OrderProfit()/AccountEquity() >= _tp_percent)
                             {
                                 ResetLastError();
                                 if(!OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),10,clrNONE))
                                   {
                                       printf(__FUNCSIG__+" failed to close order with error: "+IntegerToString(GetLastError()));
                                   }
                             }
                       }
                 }
           }
  }

pse see above

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

Yes, thank you for the code, but it has only 2 inputs: magic number and implying 5% which I believe is for the equity Tp. I need to have an equity stop loss as well and upon closure should close all live and pending orders. It should be symbol specific, that is must control only the equity of that particular symbol with its settings and close orders of those symbols only when settings are satisfied. Equity Tp and Sl should have atleast 3 decimal points for the input option.

Can you make it like that please?

Thank you once again for the code.