I just need to call the function, that's all I need is one line "If there is more orders than one .... and that's all" - and you're offering me a whole function
Here is how I store my order data
It's a simple one, put it in the library.
The type of an order to be counted and its master is given as input, it returns the number of open or set orders.
int ChPos( int TypePos,int Magic)
{
// возвращает кол-во позицй которые открыты или выставленн отложками с магиком Magic int i;
int count=0 ;
for( i=0; i < OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS)==true)
{
if(OrderType()==OP_BUY && TypePos==OP_BUY && Magic==OrderMagicNumber()){count++;}
if(OrderType()==OP_SELL && TypePos==OP_SELL && Magic==OrderMagicNumber()){count++;}
if(OrderType()==OP_BUYLIMIT && TypePos==OP_BUYLIMIT && Magic==OrderMagicNumber()){count++;}
if(OrderType()==OP_BUYSTOP && TypePos==OP_BUYSTOP && Magic==OrderMagicNumber()){count++;}
if(OrderType()==OP_SELLLIMIT && TypePos==OP_SELLLIMIT && Magic==OrderMagicNumber()){count++;}
if(OrderType()==OP_SELLSTOP && TypePos==OP_SELLSTOP && Magic==OrderMagicNumber()){count++;}
}
}
return(count);
}
You can use it in the following way
if ((FastEma - SmallEma) > Compartor*Point && ChPos(OP_BUY,1111) < OpenPosition)
Input is the type of order to be counted and its master, it returns the number of open or set orders .
This can be used in the following way
if ((FastEma - SmallEma) > Compartor*Point && ChPos(OP_BUY,1111) < OpenPosition)
I have such a function and I don't need it, I just need just one line "if there are more orders than one .... then" and that's it
my data for the same function you've shown is stored here
int total_order; // переменная в которой хранится общее количество открытых ордеров в терминалеint my_total_order; // переменная в которой хранится общее количество открытых ордеров с нашим Magic
if (your condition && aaa < OrdersHistoryTotal()+ OrdersTotal() )
{
operators
aaa=OrdersHistoryTotal()+ OrdersTotal()
}
If so, it's still better to put it into a function with magicians in mind . Can you tell us what you are working on? Logic is a bit strange if I got it right, when one more order is opened, isn't it easier to open orders no larger than OpenPosition?
Your function returns the total number of open orders and placed pending orders. How many orders OP_BUY, if there is OP_BUYLIMIT OP_SELLLIMIT OP_SELL etc. it does not show.
Please note that it is highlighted in red . The type of trade orders is the same and the variables in the pipe are set differently, this is how it should be .
ivandurak: Notice what is highlighted in red . The type of trade orders is the same and the variables in the pipe are set different, this is how it should be .
Yes, it should be, because there are different opening functions and I do not make a request for OrderType () and requested the flag whether it is open, but the problem is most likely not in this function because the other requests also do not work this I first threw, AND ON THE SAME FUNCTION OPEN NORMALLY
SO THE PROBLEM IS WITH THE REQUEST IN THE OPERATOR
The problem seems to be elsewhere. But I think I need to see the code.
It's definitely not elsewhere, everything else works, the problem is that the request (HaveBuyLimitOrderEnd== true) is wrong, so I'm wondering how else to tell it to modify and delete,
Yes, it should be, because there are different opening functions and I do not make a request for OrderType () and requested the flag whether it is open, but the problem is most likely not in this function because the other requests also do not work this I first threw, AND ON THE SAME FUNCTION OPEN NORMALLY
SO THE PROBLEM IS WITH THE QUERY IN THE OPERATOR
if(bt==1&&bl==7)
{OpenBuyStopOrder(Lot,PRBidS);OpenBuyLimitOrder(Lot*3,PRAskL); if (HaveBuyLimitOrderEnd== true)
{ModifyBuyStopOrder(PRAskS); // Выбираем
} }
I wonder if in functions marked red HaveBuyLimitOrderEnd is set in the pipe. If not, you need to call Myorders() before if. Otherwise you do not know what is there. And just in case, the flags (variables)
HaveBuyOrder = false; HaveSellOrder = false; HaveBuyStopOrder = false; HaveSellStopOrder = false; HaveBuyLimitOrder = false; HaveSellLimitOrder = false; HaveBuyLimitOrderEnd = false; HaveSellLimitOrderEnd = false; must be defined at global level .
I wonder if the HaveBuyLimitOrderEnd flag is set in red in the pipe. If not, you need to call Myorders() before if. Otherwise you don't know what is there. And just in case, flags (variables)
HaveBuyOrder = false; HaveSellOrder = false; HaveBuyStopOrder = false; HaveSellStopOrder = false; HaveBuyLimitOrder = false; HaveSellLimitOrder = false; HaveBuyLimitOrderEnd = false; HaveSellLimitOrderEnd = false; must be defined globally.
it is at a glabal level
bool HaveBuyOrder; // flag if there are open market buy orders bool HaveSellOrder; // flag flag of open market orders to sell bool HaveBuyStopOrder; // flag of open pending Buy orders bool HaveSellStopOrder; // flag of open pending Sell orders bool HaveBuyLimitOrder; // flag of open pending Buy orders bool HaveSellLimitOrder; // flag of open pending Sell orders bool HaveBuyLimitOrderEnd; // flag of presence of open pending Buy orders bool HaveSellLimitOrderEnd; // flag pending Sell orders open
if (OrderSelect(ticket, SELECT_BY_TICKET,MODE_TRADES)) Print("function to place a BuyStop order : ", OrderOpenPrice()) } else Print("Error # ", GetLastError(), " function for placing BuyStop order",MarketInfo(Curr_symb,MODE_ASK)); return(ticket); }
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I just need to call the function, that's all I need is one line "If there is more orders than one .... and that's all" - and you're offering me a whole function
Here is how I store my order data
It's a simple one, put it in the library.
The type of an order to be counted and its master is given as input, it returns the number of open or set orders.
You can use it in the following way
if ((FastEma - SmallEma) > Compartor*Point && ChPos(OP_BUY,1111) < OpenPosition)
It's not complicated put it in the library .
Input is the type of order to be counted and its master, it returns the number of open or set orders .
This can be used in the following way
if ((FastEma - SmallEma) > Compartor*Point && ChPos(OP_BUY,1111) < OpenPosition)
I have such a function and I don't need it, I just need
just one line "if there are more orders than one .... then" and that's it
my data for the same function you've shown is stored here
and here's what it looks like
I think I've got it.
static int aaa = OrdersHistoryTotal()+ OrdersTotal()
if (your condition && aaa < OrdersHistoryTotal()+ OrdersTotal() )
{
operators
aaa=OrdersHistoryTotal()+ OrdersTotal()
}
If so, it's still better to put it into a function with magicians in mind . Can you tell us what you are working on? Logic is a bit strange if I got it right, when one more order is opened, isn't it easier to open orders no larger than OpenPosition?
Your function returns the total number of open orders and placed pending orders. How many orders OP_BUY, if there is OP_BUYLIMIT OP_SELLLIMIT OP_SELL etc. it does not show.
I've got it figured out, now the problem with the if function is that I don't know what the problem is.
the point is that the first value is executed.
This one does not work if (HaveBuyLimitOrderEnd== true)
{ModifyBuyStopOrder(PRAskS); // Select
} }
in words, if there is an order HaveBuyLimitOrderEnd, modify it with a price change PRAskS
I can't figure out what's wrong. The value of HaveBuyLimitOrderEnd is taken from void Myorders() in the code above
the value if(bt==1&&bl==7) is main, so if it's true, use all of the following
most likely haveBuyLimitOrderEnd== true because i have set OrderLots()==3*Lot all work only it modifies orders with 0.3 lot
Notice what is highlighted in red . The type of trade orders is the same and the variables in the pipe are set different, this is how it should be .
Yes, it should be, because there are different opening functions and I do not make a request for OrderType () and requested the flag whether it is open, but the problem is most likely not in this function because the other requests also do not work this I first threw, AND ON THE SAME FUNCTION OPEN NORMALLY
SO THE PROBLEM IS WITH THE REQUEST IN THE OPERATOR
The problem seems to be elsewhere. But you should probably see the code.
The problem seems to be elsewhere. But I think I need to see the code.
It's definitely not elsewhere, everything else works, the problem is that the request (HaveBuyLimitOrderEnd== true) is wrong, so I'm wondering how else to tell it to modify and delete,
or the query itself is wrong
if(bs==1&&bl==3)
{OpenBuyLimitOrderEnd(Lot*15,PRAskL);
if (HaveBuyLimitOrderEnd== true)
{ModifyBuyStopOrder(PRAskS);
} }
Yes, it should be, because there are different opening functions and I do not make a request for OrderType () and requested the flag whether it is open, but the problem is most likely not in this function because the other requests also do not work this I first threw, AND ON THE SAME FUNCTION OPEN NORMALLY
SO THE PROBLEM IS WITH THE QUERY IN THE OPERATOR
I wonder if in functions marked red HaveBuyLimitOrderEnd is set in the pipe. If not, you need to call Myorders() before if. Otherwise you do not know what is there. And just in case, the flags (variables)
HaveBuyOrder = false;
HaveSellOrder = false;
HaveBuyStopOrder = false;
HaveSellStopOrder = false;
HaveBuyLimitOrder = false;
HaveSellLimitOrder = false;
HaveBuyLimitOrderEnd = false;
HaveSellLimitOrderEnd = false;
must be defined at global level .
I wonder if the HaveBuyLimitOrderEnd flag is set in red in the pipe. If not, you need to call Myorders() before if. Otherwise you don't know what is there. And just in case, flags (variables)
HaveBuyOrder = false;
HaveSellOrder = false;
HaveBuyStopOrder = false;
HaveSellStopOrder = false;
HaveBuyLimitOrder = false;
HaveSellLimitOrder = false;
HaveBuyLimitOrderEnd = false;
HaveSellLimitOrderEnd = false;
must be defined globally.
it is at a glabal level
bool HaveBuyOrder; // flag if there are open market buy orders
bool HaveSellOrder; // flag flag of open market orders to sell
bool HaveBuyStopOrder; // flag of open pending Buy orders
bool HaveSellStopOrder; // flag of open pending Sell orders
bool HaveBuyLimitOrder; // flag of open pending Buy orders
bool HaveSellLimitOrder; // flag of open pending Sell orders
bool HaveBuyLimitOrderEnd; // flag of presence of open pending Buy orders
bool HaveSellLimitOrderEnd; // flag pending Sell orders open
it's in the order opening function.
ticket = OrderSend(Curr_symb,OP_BUYSTOP, Lot, PRAskS, Slippage, SL, TP, 0, Magic, 0, CLR_NONE);
if (ticket > 0) {
HaveBuyStopOrder = true;
if (OrderSelect(ticket, SELECT_BY_TICKET,MODE_TRADES)) Print("function to place a BuyStop order : ", OrderOpenPrice())
}
else Print("Error # ", GetLastError(), " function for placing BuyStop order",MarketInfo(Curr_symb,MODE_ASK));
return(ticket);
}
SO EVERYTHING ELSE WORKS