Would you mind to edit your post and put your code in the source box - use the SRC-button in the edit line!
-
Play videoPlease edit your post.
For large amounts of code, attach it. - akuh: If i put LastOT in my buy sell condition i get the message "undeclared identifier". Why do i get this message ?LastOT is declared inside LastOrderType() therefor it's not available outside. You call your function and it returns a int. What do you do with the value?
Carl Schreiber:
Would you mind to edit your post and put your code in the source box - use the SRC-button in the edit line!
Would you mind to edit your post and put your code in the source box - use the SRC-button in the edit line!
Ok i think i have solved the problem !
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
Dear Mql5 community,
Im working on an EA and i want to put the command:
I want the EA to put no new buy order, if the last order was a buy order, and the other way round with the sell order. therefore i found the following command to get the type of last closed order:
int LastOrderType()
{
datetime TicketTime = 0;
int TicketN,
LastOT;
for (int ix = 0; ix < OrdersHistoryTotal(); ix++)
{
if(OrderSelect(ix, SELECT_BY_POS, MODE_HISTORY)
&& OrderMagicNumber() == Magic
&& OrderSymbol() == Symbol())
{
if (OrderCloseTime() > TicketTime)
{
TicketTime = OrderCloseTime(); //For testing
TicketN = OrderTicket(); //For testing
LastOT = OrderType();
}
}
else
Print("OrderSelect returned the error of ",GetLastError());
}
Print("Last closed order: ",TicketN," ",TicketTime," ",LastOT); //For testing
return(LastOT); // Buy==0, Sell==1, Others==2 through 5
}// End Last Order Type
Now i want to put "LastOT" in my buy/sell condition. The EA shall only open an Buy Order if the last Order was Sell order and the other way round. If i put LastOT in my buy sell condition i get the message "undeclared identifier". Why do i get this message ?
akuh