hi
i miss one future order where the error is 0 no error
s1ticket is not executed !
why ?
void StartOrders()
{
if ( DayOfWeek() == day_ && Hour()== hour_ && Minute() == minute_ )
{
Ask_price_zero = Ask;
Bid_price_zero = Bid;
double Ask_Norm=NormalizeDouble(Ask,Digit_Info);
double Bid_Norm=NormalizeDouble(Bid,Digit_Info);
//#################################################################
double Pip_Multiple=Point_Info;
if(Digit_Info==3){Pip_Multiple=0.01;}
if(Digit_Info==5){Pip_Multiple=0.0001;}
//#################################################################
Future_PriceBuy=Ask_Norm+(Future_Pips*Pip_Multiple);
if(Future_PriceBuy<Ask_Norm+(Stop_Info*Point_Info)){
Future_PriceBuy=Ask_Norm+(Stop_Info*Point_Info);
}
//----------
Future_PriceSell=Bid_Norm-(Future_Pips*Pip_Multiple);
if(Future_PriceSell>Bid_Norm-(Stop_Info*Point_Info)){
Future_PriceSell=Bid_Norm-(Stop_Info*Point_Info);
}
B1Ticket =
OrderSend(Symbol(),OP_BUYSTOP,2*Lots,Future_PriceBuy,
Slippage,Future_PriceBuy-20*Point_Info,Future_PriceBuy+10*Point_Info,"Gabriel_BuyStop",3,0,Green);
// Comment ("buy OrderSend failed with error #", GetLastError());
B2Ticket =
OrderSend(Symbol(),OP_BUYSTOP,Lots,Future_PriceBuy+10*Point_Info,
Slippage,Future_PriceBuy-10*Point_Info,0,"Gabriel_BuyStop",3,0,Green);
S1Ticket =
OrderSend(Symbol(),OP_SELLSTOP,2*Lots,Future_PriceSell,
Slippage,Future_PriceSell+20*Point_Info,Future_PriceSell-10*Point_Info,"Gabriel_SellStop",3,0,Red);
S2Ticket =
OrderSend(Symbol(),OP_SELLSTOP,Lots,Future_PriceSell-10*Point_Info,
Slippage,Future_PriceSell+10*Point_Info,0,"Gabriel_SellStop",3,0,Red);
if ( B1Ticket<0 || B2Ticket<0 || S1Ticket<0 || S1Ticket< 0 )
{
err = GetLastError();
Alert("error future order = "+ErrorDescription(err)); }
start_orders = true;
}
return ;
} /* StartOrders */
double Pip_Multiple=Point_Info; if(Digit_Info==3){Pip_Multiple=0.01;} if(Digit_Info==5){Pip_Multiple=0.0001;}
You must adjust TP, SL, and slippage for 5 digit brokersdouble pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
- On ECN brokers you can't set SL/TP with orderSend, must modify the order after.
You need to use GetLastError() after each OrderSend. Otherwise the last error code is being reset and you cannot catch the real error (error code becomes 0).
u should use
#include <stdlib.mqh>
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi
i miss one future order where the error is 0 no error
s1ticket is not executed !
why ?
void StartOrders()
{
if ( DayOfWeek() == day_ && Hour()== hour_ && Minute() == minute_ )
{
Ask_price_zero = Ask;
Bid_price_zero = Bid;
double Ask_Norm=NormalizeDouble(Ask,Digit_Info);
double Bid_Norm=NormalizeDouble(Bid,Digit_Info);
//#################################################################
double Pip_Multiple=Point_Info;
if(Digit_Info==3){Pip_Multiple=0.01;}
if(Digit_Info==5){Pip_Multiple=0.0001;}
//#################################################################
Future_PriceBuy=Ask_Norm+(Future_Pips*Pip_Multiple);
if(Future_PriceBuy<Ask_Norm+(Stop_Info*Point_Info)){
Future_PriceBuy=Ask_Norm+(Stop_Info*Point_Info);
}
//----------
Future_PriceSell=Bid_Norm-(Future_Pips*Pip_Multiple);
if(Future_PriceSell>Bid_Norm-(Stop_Info*Point_Info)){
Future_PriceSell=Bid_Norm-(Stop_Info*Point_Info);
}
B1Ticket =
OrderSend(Symbol(),OP_BUYSTOP,2*Lots,Future_PriceBuy,
Slippage,Future_PriceBuy-20*Point_Info,Future_PriceBuy+10*Point_Info,"Gabriel_BuyStop",3,0,Green);
// Comment ("buy OrderSend failed with error #", GetLastError());
B2Ticket =
OrderSend(Symbol(),OP_BUYSTOP,Lots,Future_PriceBuy+10*Point_Info,
Slippage,Future_PriceBuy-10*Point_Info,0,"Gabriel_BuyStop",3,0,Green);
S1Ticket =
OrderSend(Symbol(),OP_SELLSTOP,2*Lots,Future_PriceSell,
Slippage,Future_PriceSell+20*Point_Info,Future_PriceSell-10*Point_Info,"Gabriel_SellStop",3,0,Red);
S2Ticket =
OrderSend(Symbol(),OP_SELLSTOP,Lots,Future_PriceSell-10*Point_Info,
Slippage,Future_PriceSell+10*Point_Info,0,"Gabriel_SellStop",3,0,Red);
if ( B1Ticket<0 || B2Ticket<0 || S1Ticket<0 || S1Ticket< 0 )
{
err = GetLastError();
Alert("error future order = "+ErrorDescription(err)); }
start_orders = true;
}
return ;
} /* StartOrders */