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.
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(); ..
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.- Can't use periods in variable names, since February 3, 2014 (Build 600)
- Simple caching of function calls: period.chart = Period();
- Can't use periods in variable names, since February 3, 2014 (Build 600)
- Simple caching of function calls: period.chart = Period();
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)) { }
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())?
- Your post is #7. What part of it #5 is unclear?
- Only if you need to convert TF to text — when in doubt, THINK.
- Example of finding orders — when in doubt, THINK.
- When in doubt, THINK — do you really expect an answer? only you know your code.
- 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.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.