return(OrderSend(neueOrder,result));
if(!OrderSend(neueOrder,result))
PrintFormat("OrderSend error %d",GetLastError()); // wenn die Anfrage konnte nicht gesendet werden, den Fehlercode anzeigen
//--- Details zur Transaktion
PrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order);
You "return" there, so of course the remaining code is never executed.
Fix it and see what will be printed as information. Also report the result of the print in your StoppOrder() function.
Hello Alain,
the interresting thing is,
why is the order executed when i will send a buy oder and not when i will send a short order?
how you mean i should fix the return function, do you mean
amando
Hello Alain,
the interresting thing is,
why is the order executed when i will send a buy oder and not when i will send a short order?
how you mean i should fix the return function, do you mean
amando
// Alain intent : REMOVE this code ===> //return(OrderSend(neueOrder,result)); ==== and the program will run smoothly
if(!OrderSend(neueOrder,result))
PrintFormat("OrderSend error %d",GetLastError()); // wenn die Anfrage konnte nicht gesendet werden, den Fehlercode anzeigen
//--- Details zur Transaktion
PrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order);
found it out,
in a bool
const double OrderPrice,const double sl,const double tp,const int magic, const string comment)
{
MqlTradeRequest neueOrder={0};
MqlTradeResult result={0};
//--- setting request
neueOrder.symbol = symbol;
neueOrder.type = order_type;
neueOrder.action = TRADE_ACTION_PENDING;
neueOrder.type_filling = ORDER_FILLING_FOK;
neueOrder.type_time = ORDER_TIME_GTC;
neueOrder.volume = volume;
neueOrder.price = OrderPrice;
neueOrder.sl = sl;
neueOrder.tp = tp;
neueOrder.magic = magic;
neueOrder.comment = comment;
neueOrder.expiration = ORDER_TIME_SPECIFIED_DAY;
//--- action and return the result
return(OrderSend(neueOrder,result));
if(!OrderSend(neueOrder,result))
PrintFormat("OrderSend error %d",GetLastError()); // wenn die Anfrage konnte nicht gesendet werden, den Fehlercode anzeigen
//--- Details zur Transaktion
PrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order);
}
you have to use a return, bcs a bool need an return code
i changed it to a void and delete the return line and now it 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,
i have a problem with an oder send function, BuyStop is working, Sell Stop is nothing
i Use für tp2 the value 200, for Stop 2 the Value 200 and for Distanz2 values between -200 and + 200
even i do not get any error code
any idea?
amado
{
double SLOrder,TPOrder;
string LS=ObjectGetString(0,"Lot",OBJPROP_TEXT,0);
double LS1=StringToDouble(LS);
string Stop1= ObjectGetString(0,"Stopp",OBJPROP_TEXT,0);
int Stop2= StringToInteger(Stop1);
string tp1= ObjectGetString(0,"TP1",OBJPROP_TEXT,0);
int tp2= StringToInteger(tp1);
Print("Stop1 ",Stop1," TP1 ",tp1);
string Distanz1= ObjectGetString(0,"StopOrder",OBJPROP_TEXT,0);
double Distanz2= StringToDouble(Distanz1);
ENUM_ORDER_TYPE OrderType;
double Open;
if(Distanz2 > 0 ) {OrderType = ORDER_TYPE_BUY_STOP; Open = Ask()+ Distanz2 * _Point; SLOrder = Open - (Stop2*_Point); TPOrder = Open + (tp2*_Point);}
if(Distanz2 < 0 ) {OrderType = ORDER_TYPE_SELL_STOP; Open = Bid()- Distanz2 * _Point;SLOrder = Open + (Stop2*_Point); TPOrder = Open - (tp2*_Point);}
if(MathAbs(Distanz2)<StopLevel()) Print("No Stop Order possible, to less distance, You are in Stoplevel");
if(Distanz2 == 0) Print("Zero Distance is not possible, Increase distance");
Print(_Symbol," Type ",OrderType," Lot ",LS1," Open ",Open," SL ",SLOrder," TP ",TPOrder);
PendingOpen(_Symbol,OrderType,LS1,Open,SLOrder,TPOrder,MN,Text);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool PendingOpen(const string symbol,const ENUM_ORDER_TYPE order_type,const double volume,
const double OrderPrice,const double sl,const double tp,const int magic, const string comment)
{
MqlTradeRequest neueOrder={0};
MqlTradeResult result={0};
//--- setting request
neueOrder.symbol = symbol;
neueOrder.type = order_type;
neueOrder.action = TRADE_ACTION_PENDING;
neueOrder.type_filling = ORDER_FILLING_FOK;
neueOrder.type_time = ORDER_TIME_GTC;
neueOrder.volume = volume;
neueOrder.price = OrderPrice;
neueOrder.sl = sl;
neueOrder.tp = tp;
neueOrder.magic = magic;
neueOrder.comment = comment;
neueOrder.expiration = ORDER_TIME_SPECIFIED_DAY;
//--- action and return the result
return(OrderSend(neueOrder,result));
if(!OrderSend(neueOrder,result))
PrintFormat("OrderSend error %d",GetLastError()); // wenn die Anfrage konnte nicht gesendet werden, den Fehlercode anzeigen
//--- Details zur Transaktion
PrintFormat("retcode=%u deal=%I64u order=%I64u",result.retcode,result.deal,result.order);
}