![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
No solution yet programmers your assistance is needed plz am so stuck on this
You have been told the solution.
You should have a globalscope or static variable to count the trades and set it to 0 initially (or the value of OrdersTotal()).
Whenever a new trade is opened increase the counter by 1.
If OrdersTotal()==0 reset it to 0.
but you say that it is too difficult to understand.
I am unable to see how it could be explained in a simpler way.
You have been told the solution.
but you say that it is too difficult to understand.
I am unable to see how it could be explained in a simpler way.
okay, thanks for been trying to help.
let me explain all over again what i did and maybe you can probably point out where am getting wrong. i will explein and give the code
firstly i have a global variable "limit" which i set to 0(Zero) i.e "int Limit=0;
then i did a function to count only sell orders "CountSell" only, am tryin to count Position types differently so am using "SELL" to get the correct code then ill do for BUY later
so below is just the variable and the function only, just to save long pasting of entire codes since that's where am having the issue,
this is just how I fully understand your explanations you can help correct if am not getting it right
thanks
firstly i have a global variable "limit" which i set to 0(Zero) i.e "int Limit=0;
then i did a function to count only sell orders "CountSell" only, am tryin to count Position types differently so am using "SELL" to get the correct code then ill do for BUY later
Where did I say to count sell( or buy) orders?
You should have a globalscope or static variable to count the trades and set it to 0 initially (or the value of OrdersTotal()).
Whenever a new trade is opened increase the counter by 1.
If OrdersTotal()==0 reset it to 0.
Where did I say to count sell( or buy) orders?
Whenever your EA opens a trade, increase the counterI will surely need to differentiate order types for the project am running that's why am implementing that from scratch so i wont have further issues when it comes to that.
Here is a very simple code
Here is a very simple code
Thanks a bunch, your code works perfectly. Thanks once again
counter is now very okay.
i was hoping the counter will solve my main program issue and now its clear i need to look for another solution, but i learnt something new and thanks to you for that its a progress towards my goal
Thanks a bunch, your code works perfectly. Thanks once again
counter is now very okay.
i was hoping the counter will solve my main program issue and now its clear i need to look for another solution, but i learnt something new and thanks to you for that its a progress towards my goal
It's a simple code, but it may not work perfectly in all cases.
eg. if between calls a trade is closed and a new one is opened, OrdersTotal() will have the same value and the new trade will not be counted.
That is why in my earlier solution, the counter is incremented when a new trade is opened.
It's a simple code, but it may not work perfectly in all cases.
eg. if between calls a trade is closed and a new one is opened, OrdersTotal() will have the same value and the new trade will not be counted.
That is why in my earlier solution, the counter is incremented when a new trade is opened.
yeah i think that's where the problem is