Hello MQL5 community
Can someone please help me, by example; how do i close an open trade, either through a function or TP amount?
I tried this:
double myAccountProfit = AccountInfoDouble(ACCOUNT_PROFIT);
double myAccountEquity = AccountInfoDouble(ACCOUNT_EQUITY);
if (myAccountEquity - myAccountBalance > 2)
1. Please insert the code correctly: when editing a message, press the button and paste your code into the pop-up window. (The first time I corrected your message)
2. Nothing is clear from your explanation. Do you want to close all positions if the profit on your trading account is more than $ 2.0?
// ulong o_ticket = OrderGetTicket(i);
for(int j=o_total-1; j>=0; j--)
ulong o_ticket = OrderGetTicket(j);
if(o_ticket != 0)
// delete the pending order
Print("Pending order deleted sucessfully!");
Please enable the necessary setting in your browser, otherwise you will not be able to log in.