newbie, learning mql4, help with this

 

Hello Guys,

I have two demos accounts with oanda and fxcm. I niether case the order gets submitted, and GetLastError() returns 130, with means worn stop loss.

ERR_INVALID_STOPS130Invalid stops.

If I change to

ticket=OrderSend(Symbol(),OP_ BUY,Lots,Ask,3,1.4,1.5,"my EA",16384,0,Green);

I still get the same error.

thnks in advance

int ticket;
//+--------------------------- ------------------------------ ---------+
//| expert initialization function |
//+--------------------------- ------------------------------ ---------+
int init()
{
//----

//----
return(0);
}
//+--------------------------- ------------------------------ ---------+
//| expert deinitialization function |
//+--------------------------- ------------------------------ ---------+
int deinit()
{
//----

//----
return(0);
}
//+--------------------------- ------------------------------ ---------+
//| expert start function |
//+--------------------------- ------------------------------ ---------+
int start()
{
//----
ticket=OrderSend(Symbol(),OP_ BUY,Lots,Ask,3,Ask-0.0099,Ask+ 0.0099,"my EA",16384,0,Green);
if(ticket>0){
if(OrderSelect(ticket,SELECT_ BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());

Print(Ask," ",Bid);
return(0);
}
 

there is not problem if and dont set stop_loss or take_profits and put zeros there...

 
ticket=OrderSend(Symbol(),OP_ BUY,Lots,Ask,3,Ask-0.0099,Ask+ 0.0099,"my EA",16384,0,Green);

  1. EAs must adjust for 4/5 digit brokers, TP, SL AND SLIPPAGE
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  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
    
  2. On ECN brokers you must open first and THEN set stops.
  3. Next time use this
 
ciremql4:

Hello Guys,

I have two demos accounts with oanda and fxcm. I niether case the order gets submitted, and GetLastError() returns 130, with means worn stop loss.

ERR_INVALID_STOPS130Invalid stops.

If I change to

ticket=OrderSend(Symbol(),OP_ BUY,Lots,Ask,3,1.4,1.5,"my EA",16384,0,Green);

I still get the same error.

thnks in advance

int ticket;
//+--------------------------- ------------------------------ ---------+
//| expert initialization function |
//+--------------------------- ------------------------------ ---------+
int init()
{
//----

//----
return(0);
}
//+--------------------------- ------------------------------ ---------+
//| expert deinitialization function |
//+--------------------------- ------------------------------ ---------+
int deinit()
{
//----

//----
return(0);
}
//+--------------------------- ------------------------------ ---------+
//| expert start function |
//+--------------------------- ------------------------------ ---------+
int start()
{
//----
ticket=OrderSend(Symbol(),OP_ BUY,Lots,Ask,3,Ask-0.0099,Ask+ 0.0099,"my EA",16384,0,Green);
if(ticket>0){
if(OrderSelect(ticket,SELECT_ BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());

Print(Ask," ",Bid);
return(0);
}

also I am newby

but my broker wont let me set stops or Take Profit when i open trade

so i set SL and TP to 0


and as soon as trade is accepted i place stops and Take profits

some broker dont need this

Reason: