what do you want it to do?
if(OrderType()== OP_BUYSTOP) //////// this means you testing for OP_BUYSTOP
but then when you get to
else { //////// this means everything else? OP_BUY, OP_SELL, OP_SELLSTOP
so rather do:
if(OrderType()== OP_BUYSTOP) {
Print("have OP_BUYSTOP");
}else if(OrderType()== OP_SELLSTOP){
Print("have OP_SELLSTOP");
}else if(OrderType()== OP_BUY){
Print("have OP_BUY");
}else if(OrderType()== OP_SELL){
Print("have OP_SELL");
}else{
Print("spend your time doing something else");
}
or you can use a switch:
switch (OrderType())
{
case OP_BUY:
Print("have OP_BUY");
case OP_SELL:
Print("have OP_SELL");
}
what do you want it to do?
<CODE DELETED>
Please read some other posts before posting . . .
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
i want to check both of BuyStop and SellStop
else { //////// this means everything else? OP_BUY, OP_SELL, OP_SELLSTOP
Yeah, that is my problem, thank you
I try another one, i have 1 BuyStop and 1 SellStop but it print : "buystoporder = 0 sellstoporder = 0" :(
int start()
{
int BuyStopOrder;
int SellStopOrder;
for(int j=0; j<OrdersTotal(); j++)
{
if(OrderSelect(j,SELECT_BY_POS))
{
switch ( OrderType() )
{
case OP_BUYSTOP: BuyStopOrder = OrderTicket(); break;
case OP_SELLSTOP: SellStopOrder = OrderTicket(); break;
}
Print("buystoporder="+BuyStopOrder+ " sellstoporder =",SellStopOrder);
}
else
{
Print( "Error when order select ", GetLastError());
}
break;
}
//----
return(0);
}
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Plz help me, i don't know what wrong :(
extern double Lot = 0.01;
extern int TakeProfit = 200;
extern int StopLoss = 2500;
extern int Distance = 250;
int init()
{
string name;
double normprice;
for(int i=0;i<OBJ_HLINE;i++)
{
name=ObjectName(i);
normprice=NormalizeDouble(ObjectGet(name,OBJPROP_PRICE1),3);
Print("Gia cua duong line = ",normprice);
}
return(0);
}
int start()
{
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()== OP_BUYSTOP)
{
if(OrderType()== OP_SELLSTOP)
{
Print("Have buystop and sellstop");
}
else
{
Print("Have buystop but dont have sellstop");
}
}
else
{
if(OrderType()== OP_SELLSTOP)
{
Print("Dont have buystop but have sellstop");
}
else
{
Print("Dont have buystop and sellstop");
}
}
}
else
{
Print( "Error when order select ", GetLastError());
}
break;
}
//----
return(0);
}
//+------------------------------------------------------------------+