You need to read the Book and the Documentation . . .
for (int i = total - 1; i >= 0; i --) { if (OrderMagicNumber() == magic) // <-------------- for which order ? ? {
Read OrderMagicNumber() and OrderSelect()
Hi!
Have attached some more pictures (combined):
LEFT - same as above - I say YES BE, EA says NO BE | MIDDLE - I say YES BE, EA says YES BE (at least once a while we agree LOL) | RIGHT - I say NO BE, EA says YES BE ("No way!", I add. "Not possible, no trades!". "Never mind, yes break even.", replies calmly EA. Must be some distant relative of Zaphod Bebbleebrox LOL).
Raptor, Raptor, Raptor!
You are da MAN!
Works now:
// ----- LAST IS BREAK EVEN ----- void lastIsBE () { // LastIsBE = false; //disable ? - instead of declaring at start function - NOT WORKING int total = OrdersTotal(); for (int i = total - 1; i >= 0; i --) { OrderSelect (i, SELECT_BY_POS, MODE_TRADES); // <-- Noughty noughty line, where were you all this time? Shame on you, you made me sooo worried! if (Symbol() == OrderSymbol() && OrderMagicNumber() == magic) { // ----- BUY ORDER - HAS OrderStopLoss() >= OrderOpenPrice() + MoveSLTo * Point ----- if (OpenOrdersNew [1,3] == 0) // last buy order { if (OpenOrdersNew [1,6] >= OpenOrdersNew [1,5] + (MoveSLTo * Point)) // last OrderStopLoss() >= OrderOpenPrice() { LastIsBE = true; //continue;//setGV ("LastIsBE" + Test, 1); } else { LastIsBE = false; //setGV ("LastIsBE" + Test, 0); } // continue; } // ----- SELL ORDER - HAS OrderStopLoss() <= OrderOpenPrice() - MoveSLTo * Point ----- if (OpenOrdersNew [1,3] == 1) // last sell order { if (OpenOrdersNew [1,6] <= OpenOrdersNew [1,5] - (MoveSLTo * Point)) { LastIsBE = true; //setGV ("LastIsBE" + Test, 1); } else { LastIsBE = false; //setGV ("LastIsBE" + Test, 0); } } } } return (0); // enable this? it just returns to start() }
Now, do I need to have 'return(0);' at user-defined functions, at end, or not? Most of user-defined I have seen do not have it!
And, if I would write:
OrderSelect ( >1<, SELECT_BY_POS, MODE_TRADES);
would that select last order? Considering that I would count from last toward first.
RaptorUK, muchas gracias, shall never forget you!
Best regards,
Simon
it's RaptorUK not Raptor. https://www.mql5.com/en/forum/139661
Carefully look at OrderSelect() of first code on your first post.
That's how to correctly use OrderSelect() .
Now, do I need to have 'return(0);' at user-defined functions, at end, or not? Most of user-defined I have seen do not have it!
Dear fellows!
Anybody willing to take a peek into my code? It seem to be not working properly after all.
Must be catch somewhere else, since I had same troubles (EA lying to me directly into my eyes!) with previous code.
Run out of ideas... and will...
Thank you for your support along this dirty "wanna-be-coder" road.
Frankly, I was thinking to rent a coder, but am currently (read - last 2 years) unemployed, and therefore bit short.
Nevermind,
Have fun,
Simon
S love nia
P.S: Sorry, RaptorUK, those protesting boards were bit small, I didn't know that picture would be so big. But, I think you got the idea of me thanking you. Beside, I was constantly beeing distracted by black & white lady, especially white! LOL!
Not for type void . . void means the Function doesn't return anything . . . read this thread, it should help: What are Function return values ? How do I use them ?
Not sure what exactly do you mean. I have heard this statment often, but...
int count = 0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { Alert ("Initialized!"); return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { double price = Bid; count(); Alert ("New tick no. " + count + ", price is " + price); return(0); } //+------------------------------------------------------------------+ //| expert custom functions | //+------------------------------------------------------------------+ void count() // <-- void { count++; }
... returns a value of int count.
Regards,
May the Pips fall into your account,
Simon
S love nia

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello!
Me Simon. I have CTRL-C -> CTRL-V coded EA. Then I have bit recoded it, since I have learned bit on the go. Had problem with 'lastIsBE' function. So recoded it again, especialy this mentioned function. But... still have same problem as before - although last open order is break even, EA says it is not. I have tried to persuade this EA of mine, we have had looong conversations, many a nights. He is still stubborn (must have got this after me LOL), and insist that some open orders are not break even, no matter that is obvious from chart that they are. It sometimes work, sometimes not. Using Alpari UK.
The code is from mql4Book. You know, I did my homework. But my home does not work. LOL!
#include file has this:
EA has this:
Now, as I said, sometimes it works, then not. It works flawless on Tester, then I have put EA on multiple charts, iiiiikkk!
"I can not do this for you!", said Agent SukrChi EA. "Why not?", I replied. "I am too old for this!", replied EA. "No you are not! You have just come into existence!". And the conversation went on...
As many before me, I have exhausted my tweak-the-code ideas.
Thank you for your help,
best regards,
Simon