Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart .

To add comments, please log in or register
barnacle7
309
barnacle7  

If I run the EA on 1 chart, 1 currency eg:AUDUSD only, it identifies the Ordersymbol == Symbol() , When I run the same EA on another chart with another currrency attached Eg:EURUSD on the same MT4 platform (2 currencies running on seperate charts) it returns "false" Ordersymbol doesnt equal Symbol() for EURUSD only, but AUDUSD still Equals OrderSymbol() to Symbol().

If I just run 1 currency on 1 chart it works well.  

I have put code into the Trailingstop section to return an Alert when the Ordersymbol doen't equal symbol as this is were I started having problems was with the Trailing Stop wasn't triggering when the criteria was meet.

 

Any assitance is appreciated. 

Ubzen
5298
Ubzen  

Symbol() equals Attached_Chart_Symbol.

You want to give it a Magic_Number. Use that within the OrderSend.

Remove the if (OrderSymbol()!=Symb)continue;

Add instead if (OrderMagicNumber() != Magic_Number){ continue; }

Simon Gniadkowski
17202
Simon Gniadkowski  
barnacle7:

 

 

If I run the EA on 1 chart, 1 currency eg:AUDUSD only, it identifies the Ordersymbol == Symbol() , When I run the same EA on another chart with another currrency attached Eg:EURUSD on the same MT4 platform (2 currencies running on seperate charts) it returns "false" Ordersymbol doesnt equal Symbol() for EURUSD only, but AUDUSD still Equals OrderSymbol() to Symbol().

If I just run 1 currency on 1 chart it works well.   

If you have 2 open trades, one for AUDUSD and one for EURUSD then what you are seeing is correct behaviour.  You do actually want the EA running on EURUSD to identify the AUDUSD order but you don't want it to process them.
William Roeder
19997
William Roeder  

The EA must be able to isolate its trades from all others - Same or other EAs on the same or other charts.

Adding a magic number filter to the order select loop is sufficient if all EAs on all charts are using a unique one.

If you add the EA to another pair and forget to change the magic number, they'll interfere with each other. Adding a symbol filter to the order select loop over comes the human's forgetfulness.

If you add the EA to the same pair but different timeframe then again you have the same problem. I have the EA use a range of numbers to over come this.
extern int     Magic.Number.Base          = 20130213;
int init(){
   int      chrt.tf[]={ 0, PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30,
                           PERIOD_H1, PERIOD_H4, PERIOD_D1,  PERIOD_W1        };
   string   text.tf[]={ "n/a",   "M1",      "M5",      "M15",      "M30",
                                 "H1",      "H4",      "D1",       "W1"       };
   if(Chart.iTF == 0)   while(period.chart > chrt.tf[Chart.iTF])  Chart.iTF++;
   period.market  = chrt.tf[Chart.iTF];
   magic.number   = Magic.Number.Base + Chart.iTF;
}
bool     MySelect(int iWhat, int eSelect, int ePool=MODE_TRADES){
   if(!OrderSelect(iWhat, eSelect, ePool) )  return (false);
   if(OrderMagicNumber() != magic.number  )  return (false);
   if(OrderSymbol()      != symbol.chart  )  return (false);
   if(ePool != MODE_HISTORY               )  return (true);
   return(OrderType() <= OP_SELL);  // Avoid cr/bal https://www.mql5.com/en/forum/126192
                                    // https://www.mql5.com/en/forum/124726
                                    // Never select canceled orders.
}
/////////////////////////////////////////////////////////////////////////////////////////
      for(int iPos = OrdersTotal()-1; iPos >= 0; iPos--) if(
         MySelect(iPos, SELECT_BY_POS)
      ){ oo.ticket   = OrderTicket(); ..
xanderhinds
108
xanderhinds  
whroeder1:

The EA must be able to isolate its trades from all others - Same or other EAs on the same or other charts.

Adding a magic number filter to the order select loop is sufficient if all EAs on all charts are using a unique one.

If you add the EA to another pair and forget to change the magic number, they'll interfere with each other. Adding a symbol filter to the order select loop over comes the human's forgetfulness.

If you add the EA to the same pair but different timeframe then again you have the same problem. I have the EA use a range of numbers to over come this.
In this code what is this and how is it given value?
period.chart
William Roeder
19997
William Roeder  
  1. Can't use periods in variable names, since February 3, 2014 (Build 600)
  2. Simple caching of function calls: period.chart = Period();
xanderhinds
108
xanderhinds  
whroeder1:
  1. Can't use periods in variable names, since February 3, 2014 (Build 600)
  2. Simple caching of function calls: period.chart = Period();
Thanks, you're a star!
D p Canidae
55
D p Canidae  
William Roeder:

The EA must be able to isolate its trades from all others - Same or other EAs on the same or other charts.

Adding a magic number filter to the order select loop is sufficient if all EAs on all charts are using a unique one.

If you add the EA to another pair and forget to change the magic number, they'll interfere with each other. Adding a symbol filter to the order select loop over comes the human's forgetfulness.

If you add the EA to the same pair but different timeframe then again you have the same problem. I have the EA use a range of numbers to over come this.

You used (.) to join two words together e.g test.tf.

if i try to name "variables" like that. it shows a warning semicolon need.

string symbol_chart = Symbol();

 how will text.tf[] be used,

in this code?

what the function of the "text.tf[]" array variable  

string text_tf[]={ "n/a",  "M1",    "M5",    "M15",      "M30",
                              "H1",    "H4",    "D1",       "W1"     };

1. whats the job of the "For loop"?

2. should i make it a function?

3. should it be in any function. e.g (deinit(), Init() or start())?

 for(int iPos = OrdersTotal() -1; iPos >= 0; iPos--) 
      if(MySelect(iPos, SELECT_BY_POS))
         {
         
         }
William Roeder
19997
William Roeder  
D p Canidae:

You used (.) to join two words together e.g test.tf. if i try to name "variables" like that. it shows a warning semicolon need.

 how will text.tf[] be used,

1. whats the job of the "For loop"?

2. should i make it a function?

3. should it be in any function. e.g (deinit(), Init() or start())?

  1. Your post is #7. What part of it #5 is unclear?
  2. Only if you need to convert TF to text — when in doubt, THINK.
  3. Example of finding orders — when in doubt, THINK.
  4. When in doubt, THINK — do you really expect an answer? only you know your code.
  5. You should stop using the old event handlers and IndicatorCounted and start using the new ones.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference
              How to do your lookbacks correctly.
To add comments, please log in or register