Hello forum,
I am looking into creating this static variable containing the type of last order just closed (returning OP_BUY, OP_SELL, etc), I am calling it, say, LastOrderTYPE - for further use as a condition for next opening.
market is closed for "trial and error", so I am kindly asking: what variable type should it be?
static int LastOrderType?
static string LastOrderType?
static char LastOrderType?
....?
Thanks for enlightening me! :-)
Dan.
Well OrderType is of type int
https://docs.mql4.com/trading/ordertype
so use a static int to hold the previous value
Hello forum,
I am looking into creating this static variable containing the type of last order just closed (returning OP_BUY, OP_SELL, etc), I am calling it, say, LastOrderTYPE - for further use as a condition for next opening.
market is closed for "trial and error", so I am kindly asking: what variable type should it be?
You don't need the Market to be open to test code . . . use the Strategy Tester . . .
I am looking into creating this static variable containing the type of last order just closed (returning OP_BUY, OP_SELL, etc), I am calling it, say, LastOrderTYPE
int tickets[], nTickets = GetHistoryOrderByCloseTime(tickets); if (nTickets == 0){ : } else if (!OrderSelect(tickets[0], SELECT_BY_TICKET)){ Alert("OrderSelect(",tickets[0],") failed: ", GetLastError()); : } else{ int LastOrderTYPE = OrderType(); : }
Thanks all, working on it !!! Fair enough WHRoeder, that should work as well, I will look into it .
Well OrderType is of type int
Hello again! I'm almost there, via static variables (my original plan)..
One thing: it looks like in terms of integers, OP_BUY returns 0 and OP_SELL returns 1 ? Correct?
I need to work this out as "no order" will also return 0, so I think this is confusing the signal..
Thanks again!!
Dan
One thing: it looks like in terms of integers, OP_BUY returns 0 and OP_SELL returns 1 ? Correct?
I need to work this out as "no order" will also return 0, so I think this is confusing the signal..
It is considered poor programming practice to rely on the absolute value of a symbolic constant like OP_BUY. Needless to say such poor practices are commonplace on this site :-(
And meta quotes almost encourage it ...
https://docs.mql4.com/constants/trading
You could return -1 as a no trade as that is a common error value in MQL4.
It is considered poor programming practice to rely on the absolute value of a symbolic constant like OP_BUY. Needless to say such poor practices are commonplace on this site :-(
And meta quotes almost encourage it ...
https://docs.mql4.com/constants/trading
You could return -1 as a no trade as that is a common error value in MQL4.
Thanks! True... I will probaly add an extra string type on top of it, taking values "Buy"/"Sell" based on the how OP_BUY/SELL is returned. Whatever works! : )
- 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 forum,
I am looking into creating this static variable containing the type of last order just closed (returning OP_BUY, OP_SELL, etc), I am calling it, say, LastOrderTYPE - for further use as a condition for next opening.
market is closed for "trial and error", so I am kindly asking: what variable type should it be?
static int LastOrderType?
static string LastOrderType?
static char LastOrderType?
....?
Thanks for enlightening me! :-)
Dan.