Hi all,
I'm trying to generate the current open trade type but with the following code but the result is always 0 even when the current trade is a SELL.
I've adapted the same function to collect the last (history) type trade and it worked fine.
For this function i've changed the OrdersTotal for OrdersHistoryTotal and MODE_TRADES for MODE_HISTORY.
Any thoughts?
thank you in advance!
Andrés
I think you need to find last ticket number first..
after that you can find last order type with a ticket number
and +
int LastOT;
LastOT should be -1, due to zero means OP_BUY
Hi all,
I'm trying to generate the current open trade type but with the following code but the result is always 0 even when the current trade is a SELL.
I've adapted the same function to collect the last (history) type trade and it worked fine.
For this function i've changed the OrdersTotal for OrdersHistoryTotal and MODE_TRADES for MODE_HISTORY.
Any thoughts?
thank you in advance!
Andrés
What would you start from order 1... why not starting from order "0". orders positions starts from "0"
for(int ix = 0; ix < OrdersTotal(); ix++)
if(OrderOpenTime() > TicketTime)
{
LastOT = OrderType();
}
-
You don't update TicketTime, so you are not getting the latest.
-
Do not assume history has only closed orders.
OrderType() == 6, 7 in the history pool? - MQL4 programming forum (2017) -
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum (2012)
Taking the last profit and storing it in a variable | MQL4 - MQL4 programming forum #3 (2020) -
Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
"balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)Broker History FXCM Commission - <TICKET>
Rollover - <TICKET>>R/O - 1,000 EUR/USD @0.52 #<ticket> N/A OANDA Balance update
Financing (Swap: One entry for all open orders.)
-
You don't update TicketTime, so you are not getting the latest.
-
Do not assume history has only closed orders.
OrderType() == 6, 7 in the history pool? - MQL4 programming forum (2017) -
Do not assume history is ordered by date, it's not.
Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum (2012)
Taking the last profit and storing it in a variable | MQL4 - MQL4 programming forum #3 (2020) -
Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
"balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)Broker History FXCM Commission - <TICKET>
Rollover - <TICKET>>R/O - 1,000 EUR/USD @0.52 #<ticket> N/A OANDA Balance update
Financing (Swap: One entry for all open orders.)
Hi William,
for point 1 I'm not following you. TicketTime is always zero in order to trigger the if settence when a order is open and I'm not getting any value at all.
The idea is to store the result into an array and use it later (I have this part covered), the issue is that i'm not getting the correct value when the trade happens.
for point 2 and 3, thank you it's a good tip. I could be a work around. Nonetheless for my knowledge I'm will pursue and try to fix the current code.
Thank you.
I think you need to find last ticket number first..
after that you can find last order type with a ticket number
and +
LastOT should be -1, due to zero means OP_BUY
Thank you Ahmet.
I will check it out how to call last ticket number.
And thank you for the good tip on LastOT.
Not necessarily.
A pending order triggering could be the last trade opened, but it may not have the biggest number.
The biggest number may be the remainder from a partial close order, but it may not be the last trade opened.
right
may be it helps to find https://www.mql5.com/en/forum/109180
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I'm trying to generate the current open trade type but with the following code but the result is always 0 even when the current trade is a SELL.
I've adapted the same function to collect the last (history) type trade and it worked fine.
For this function i've changed the OrdersTotal for OrdersHistoryTotal and MODE_TRADES for MODE_HISTORY.
Any thoughts?
thank you in advance!
Andrés