Maybe sum them like your variable name suggests.
Maybe sum them like your variable name suggests.
What you said you wanted
What you said you wanted
By summing "+=", just as suggested!
sum+=OrderProfit()+OrderCommission()+OrderSwap();
Obviously, this is only a simplistic outlook, because the rest of your code would have to be changed to accommodate looking at all the trades and not just the last one.
You need to first learn the basics of coding (eg. by learning about "+=", otherwise you will never get it)!
Also, learn to make your code well spaced out and indented so as to make it more readable and detect possible problematic areas!
double sum;
Also set sum to zero before entering a loop.
By summing "+=", just as suggested!
Obviously, this is only a simplistic outlook, because the rest of your code would have to be changed to accommodate looking at all the trades and not just the last one.
You need to first learn the basics of coding (eg. by learning about "+=", otherwise you will never get it)!
Also, learn to make your code well spaced out and indented so as to make it more readable and detect possible problematic areas!
sum+=OrderProfit()+OrderCommission()+OrderSwap();
THANK YOU so much i REALLY APPRECIATE your EFFORT.
i was about to say that your idea wont work but i just decided to try it out (at least no harm in trying) and to my surprise it workede just as i wanted the only thing i added was this "+" THANKS A LOT.....also i will try to space and indent my codes
ONCE AGAIN THANKS.
Also set sum to zero before entering a loop.
double sum;
i thought the value of sum will automatically be 0
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 guy, the piece of code above gives the amount of loss or profit of a particular trade and i want my EA to stop trading after a certain loss is acquired for example if a loss of -$2 is made for two consecutive times which is equal to -$4 i want the EA to stop trading.
Secondly i notice that the function TodayLastProf() stores the last profit/loss of the last trade, how do i make it store the profit/loss of the last 2-3 trade, should i use an array?