int it=OrdersHistoryTotal()-1; //---- OrderSelect(it,SELECT_BY_POS,MODE_HISTORY); { OL = OrderLots();
Using OrdersHistoryTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum- You assume history is ordered by date, it's not. Could EA Really Live
By Order_History Alone? (ubzen) - MQL4 forum
Your code if (OrderProfit() >0 && OrderLots() > Lots) {return (true);} else {return (false); }
Generic if ( true ) {return (true);} else {return (false); }
Equivalent if ( condition ) return (condition);
Simplify your code return OrderProfit() >0 && OrderLots() > Lots;
whroeder1:
- Using OrdersHistoryTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
- You assume history is ordered by date, it's not. Could EA Really Live
By Order_History Alone? (ubzen) - MQL4 forum
Your code Generic Equivalent Simplify your code
Thank you for answer
i modified the EA
double Raddoppio() { int it=OrdersHistoryTotal()-1; OL = OrderLots(); //---- OrderSelect(it,SELECT_BY_POS,MODE_HISTORY); { if ( ordinemagico() && ordprofiz() ) { Lots = NormalizeDouble(OL*2,3); } else { Lots=Lots2 ; } if ( ordprofutente() ) { raddoppiato=Lots2; } } return (Lots); } bool ordprofutente() { return OrderProfit() >0 && OrderLots() > Lots; } bool ordinemagico() { return OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol(); } bool ordprofiz() { return OrderProfit() < 0 && OrderLots() < NormalizeDouble(Lots*2,3); }
now is right?
I think I still have the same mistakes. History should be set in Closing Date order? From top to bottom or vice versa? Sorry so much but really is a bad problem. thank you in advance
Giovanni Guastella: , but I read it over and over again, but I can not understand what I should do.
int it=OrdersHistoryTotal()-1; OL = OrderLots(); //---- OrderSelect(it,SELECT_BY_POS,MODE_HISTORY);
- You select anything in history. Could be anything from any chart (a closed order, or a deleted pending order,) a balance/credit/deposit/withdrawal adjustment. Since history is not ordered by date, could be anything. Don't you want the last closed order for the current EA on the current chart? I pointed you to two links. You need to find only closed orders for the current EA on the current chart and of those, find the last one. There is no "should do," there is only a must do: learn to code it, or pay (Freelance) someone to code it. We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
- You can not use any Trade Functions until you select an order.
- What if it is the first time and there is no previous orders? Check your return codes
What are Function
return values ? How do I use them ? - MQL4 forum and Common Errors
in MQL4 Programs and How to Avoid Them - MQL4 Articles
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
please
i use it in OnTick() for get the result multiplied or reset on: int Lots, Ordersend reads it (sell for example )