Download MetaTrader 5

Looking forward to the market help.

To add comments, please log in or register
Pieu Hoang A
24
Pieu Hoang A  
Hello, everybody. Now I want to display the message.
- When the last transaction is greater than 0, it will announce a profit.
- When less than 0 will be reported as a lost.

Can anyone help me write code in programming to get that message? Please help me

Thank you very much.



whroeder1
15934
whroeder1  
Pieu Hoang A: Can anyone help me write code in programming to get that message? Please help me
Help you with what? You haven't stated a problem.
You have only four choices: 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.
Pieu Hoang A
24
Pieu Hoang A  
whroeder1:
Help you with what? You haven't stated a problem.
You have only four choices: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.

Thank you very much. 


I'm programming a robot. If the last command in the hole history, the following command will double. If that order returns, it will return to the initial value. Code in the MQL4

Marco vd Heijden
Moderator
5563
Marco vd Heijden  

Yes.

if(OrderProfit()<0
 {
  // Loss
 }

if(OrderProfit()>0)
 {
  // Profit
 }
Pieu Hoang A
24
Pieu Hoang A  
Marco vd Heijden:

Yes.


Thank u very much....!


if(OrderSelect(OrderTicket(),SELECT_BY_TICKET,MODE_HISTORY))

  {

   Print("Profit of the last transaction in the history = "+OrderProfit());

  }

  else

  {

  Print("Not..................!");

  }

But it not show for me.

Keith Watford
Moderator
10645
Keith Watford  

if(OrderSelect(OrderTicket(),SELECT_BY_TICKET,MODE_HISTORY))

This doesn't make sense unless you are re-selecting an order for some reason.

When selecting an order by ticket number, MODE_HISTORY and MODE_TRADES are ignored. ie if the above trade is an open order it will still be selected even if you have specified  MODE_HISTORY.

To add comments, please log in or register