pair specificity?
- use magic number to distinguish between distinct strategies - use OrderSymbol() to distinguish between currencies. This is pseudo-code. Check for correct syntax // code for order placement int MAGIC_EA1=1000; // check here for trade placement wih STRATEGY EA1 OrderSend(Symbol(), MAGIC_EA1, ....); // Symbol() will be eurusd if EA attached to an EURUSD chart, it will be EURJPY if...., and so on. // check here for trade placement wih STRATEGY EA2 OrderSend(Symbol(), MAGIC_EA2, ....); // Symbol() will be eurusd if EA attached to an EURUSD chart, it will be EURJPY if...., and so on. /// code for order close for(int i=OrdersTotal()-1; i>=0; i--) { if( !OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; if(OrderMagicNumber()==MAGIC_EA1) { // check close for trades with magic number MAGIC_EA1 } if(StringLowerCase(OrderSymbol())=="eurusd") // check if in your broker it isn't "EURUSDm" { // check closing conditions for eurusd } if(StringLowerCase(OrderSymbol())=="eurjpy") { // check closing conditions for eurjpy } } // this was taken from https://www.mql5.com/en/articles/1474 string StringLowerCase(string str) { string s = str; int lenght = StringLen(str) - 1, symbol; while(lenght >= 0) { symbol = StringGetChar(s, lenght); if((symbol > 64 && symbol < 91) || (symbol > 191 && symbol < 224)) s = StringSetChar(s, lenght, symbol + 32); else if(symbol > -65 && symbol < -32) s = StringSetChar(s, lenght, symbol + 288); lenght--; } return(s); }
Good morning all....I have been battling with this dillemma for awhile now and need some assistance. I have a system that I run on my real account that uses two EA's: one to place the trades once the conditions for trading have been met, and one that removes orders once my trades have closed for profit. I have a second system(that trades on totally different parameters) and I want to automate it as well. Here is my problem: the second system needs to be pair specific. I am not good at coding so right now, I basically assess accountbalance to decide whether or not to remove orders. If someone can help me by giving me a snippet of code that would look back at closed orders and search for an ordermagicnumber, then I can close an order using a different magic number. This would allow me to assign different magic numbers to the various pairs I trade and therefore be able to delete the exact right order once the first one has closed!
Any help would be greatly appreciated! Thank you.....
Daniel