![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
As I am writing for binary options I have done things a little differently:
This would probably be correct?
Here is the problem
There are 2 lines in the terminal for 1 order
And for the order which was placed by the Expert Advisor, Profit == 0
I think this is the problem
There are 2 lines in the terminal for 1 order
And on the order which has been placed by the Expert Advisor, Profit == 0
where did you find a price below zero - how do you show a screenshot?
You do not see it in this screenshot
You've already been given advice on the whole algorithm, I don't want to interfere and haven't even looked at your code and the same advice... But this
caught my eye. So my question is: Isn't it easier and more readable to use switch operator
I think it's easier to read and understand. Maybe it also works a bit faster.Maybe instead of a function just use an array volume[n] ?
Maybe so... I agree.
Where did you find a price less than zero, show me a screenshot?
There is no such thing on this screenshot.
I am trying to get OrderProfit() - it gives 0
here is a confirmation found profit -0.01 as it comes out of that additional line
![](https://c.mql5.com/3/376/Screenshot_8.png)
Maybe so... I agree.
I don't get the negative price, it's still not there.
count the total profit like this (excerpt)
What you need is highlighted
for(i=0;i<OrdersHistoryTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderType()==ORDER_TYPE_BALANCE && OrderCloseTime()>startDate)Withdrawal=Withdrawal+OrderProfit()+OrderCommission()+OrderSwap();
if((OrderType()==ORDER_TYPE_BUY || OrderType()==ORDER_TYPE_SELL))
{
if(OrderCloseTime()>iTime(Symbol(),PERIOD_D1,0))hystCurrDay=hystCurrDay+OrderProfit()+OrderCommission()+OrderSwap();
if(OrderCloseTime()<iTime(Symbol(),PERIOD_D1,0) && OrderCloseTime()>iTime(Symbol(),PERIOD_D1,1))hystPrevDay=hystPrevDay+OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
I don't get paid it's for myself and self-development. After work, it's interesting to do a grail search
Don't mind me. It's just me and Nikolay who are having a little get-together...
The essence of your problem: since OrderProfit() in forex brokerage does not give any real value, you have to define a positively/negatively closed order as the difference between the close price and the open price of the order. You have already been told about this
Forum on trading, automated trading systems and strategy testing
Check what I did wrong?
Renat Akhtyamov, 2021.12.21 09:27
do not understand the logic behind it
how come?
how the order close price may be less than zero?
the BUY order will be in the plus position if the close price is higher than the open one
here is the condition of a buy plus (excluding commissions and swap):
If it is the other way round, that's a minusI don't get paid that much for myself and my self-development. After work, it's fun to go on a grail quest.
Yes, Natalia - that was just a meme from the "When you get paid for a line of code" series.
That's the kind of humor programmers have.
![](https://c.mql5.com/3/376/2569586369970__1.png)
You don't need a function in your case.
You just need to form variables Volume1 ... Volume10 variables should be initially formed as an array volume[10]
and then refer to its elements volume[n] by index n.
Don't worry - almost every programmer has gone through this.
The main thing is that you really like programming. I can feel it.
Then you'll go far.