Error Codes

 

Hi

I am getting the error message invalid stops err 130 i.e.

I print out my values and they are as follows

2006.06.29 13:15:05 AUDUSD,H1: OrderDetails: SellPrice : 0.731 ,CurrentBid : 0.731 ,stoploss : 0.7319 ,takeprofit : 0.7291 ,slippage : 2

I am using the following to check my sl and tp before placing the order

/

if (StopLoss<=MarketInfo(Symbol(),MODE_STOPLEVEL)) StopLoss=MarketInfo(Symbol(),MODE_STOPLEVEL)+3;

if (TakeProfit<=MarketInfo(Symbol(),MODE_STOPLEVEL)) TakeProfit=2*(MarketInfo(Symbol(),MODE_STOPLEVEL)+3);

Sometimes the sell goes through like the following

2006.06.29 08:32:56 AUDUSD,H1: open #5976740 sell 0.01 AUDUSD at 0.7309 sl: 0.7324 tp: 0.7278 ok

Maybe my stops checking is just not functioning correctly.

Any suggestions?

 

I think the error lies in the way you are placing your orders. If you are using stop orders, then your orders are too close to the market price. Typically, your buy stop should be atleast "MarketInfo(Symbol(),MODE_STOPLEVEL)" pips away from the current ask.

If you are placing stop orders, make sure you use RefreshRates() and then place the orders that required distance away. For fast moving markets, it still may not work and you will have to place the orders further away.

Hope this helps.

 

it is a buy/sell not stop

Hi

Thanks but it is not a stop it is a trade - buy/sell, I will try 2*MarketInfo(Symbol(),MODE_STOPLEVEL)

 
cardio:
Hi

I am getting the error message invalid stops err 130 i.e.

I print out my values and they are as follows

2006.06.29 13:15:05 AUDUSD,H1: OrderDetails: SellPrice : 0.731 ,CurrentBid : 0.731 ,stoploss : 0.7319 ,takeprofit : 0.7291 ,slippage : 2

I am using the following to check my sl and tp before placing the order

/

if (StopLoss<=MarketInfo(Symbol(),MODE_STOPLEVEL)) StopLoss=MarketInfo(Symbol(),MODE_STOPLEVEL)+3;

if (TakeProfit<=MarketInfo(Symbol(),MODE_STOPLEVEL)) TakeProfit=2*(MarketInfo(Symbol(),MODE_STOPLEVEL)+3);

Sometimes the sell goes through like the following

2006.06.29 08:32:56 AUDUSD,H1: open #5976740 sell 0.01 AUDUSD at 0.7309 sl: 0.7324 tp: 0.7278 ok

Maybe my stops checking is just not functioning correctly.

Any suggestions?

Maybe u are using "+ 3" in both buy and sell. In sell u have to put "-3" to make it a valid price

 

that is not the hassle

I am starting to think that its interbankfx trying to prevent scalping when the market is tight. It works when the market is not tight - still it is confusing as once one's sl and tp are greater then MarketInfo(Symbol(),MODE_STOPLEVEL) it should open the trade.

Anyway Here is the code I use

StopLoss = NormalizeDouble((TradeAbovePct/100)*(DemaH-DemaL)*(1/Point),0);

if (StopLoss<=MarketInfo(Symbol(),MODE_STOPLEVEL)) StopLoss=MarketInfo(Symbol(),MODE_STOPLEVEL)+3;

TakeProfit = NormalizeDouble(2*((DemaH-DemaL)*(1/Point)),0);

if (TakeProfit<=MarketInfo(Symbol(),MODE_STOPLEVEL)) TakeProfit=2*(MarketInfo(Symbol(),MODE_STOPLEVEL)+3);

//Then I call a buy and sell as needed

//e.i

OpenBuy1(10);

OpenSell1(10);

////////////////////////////////////////////////

bool OpenBuy1(int pips1)

{

int ticket;

string comment="";

//reset defaults

use_MTBE = use_MTBEd;

use_split = use_splitd;

RefreshRates();

price1 = Ask;

stoploss1 = NormalizeDouble(price1-StopLoss*Point,Digits);

tp1 = NormalizeDouble(price1+TakeProfit*Point,Digits);

//expire1 = iTime(Symbol(),TimeFrame,0)+TimeFrame*HoursStopOpen*60;

Print("Openbuy lots: ", Lots);

if(UseStopLoss)

ticket=OrderSend(Symbol(),OP_BUY,Lots,price1,2,stoploss1,tp1,comment,MAGICMA,0,Orange);

else

ticket=OrderSend(Symbol(),OP_BUY,Lots,price1,2,0,tp1,comment,MAGICMA,0,Orange);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

{

Print("BUY order opened : ",OrderOpenPrice());

//time1 = CurTime()+2*60*Period();

return(true);

}

}

else

{

Print("Error opening BUY order : ",GetLastError());

Print("OrderDetails: BuyPrice : ",price1," ,CurrentAsk : ", Ask," ,stoploss : ",stoploss1," ,takeprofit : ",tp1," ,slippage : ",2);

return(false);

}

}

bool OpenSell1(int pips1)

{

int ticket;

string comment="";

//reset defaults

use_MTBE = use_MTBEd;

use_split = use_splitd;

RefreshRates();

price1 = Bid;

stoploss1 = NormalizeDouble(price1+StopLoss*Point,Digits) ;

tp1 = NormalizeDouble(price1-TakeProfit*Point,Digits);

// expire1 = iTime(Symbol(),TimeFrame,0)+TimeFrame*HoursStopOpen*60;

Print("Opensell lots: ", Lots);

if(UseStopLoss)

ticket=OrderSend(Symbol(),OP_SELL,Lots,price1,2,stoploss1,tp1,comment,MAGICMA,0,Red);

else

ticket=OrderSend(Symbol(),OP_SELL,Lots,price1,2,0,tp1,comment,MAGICMA,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

{

Print("SELL order opened : ",OrderOpenPrice());

// time1 = CurTime()+2*60*Period();

return(true);

}

}

else

{

Print("Error opening SELL order : ",GetLastError());

Print("OrderDetails: SellPrice : ",price1," ,CurrentBid : ", Bid," ,stoploss : ",stoploss1," ,takeprofit : ",tp1," ,slippage : ",2);

return(false);

}

}

 

Help Needed - Error 138 opening orders

Hi!

Well, as you can see, I'm newbie in this forum. I'm Ignacio, from Argentina. And I trying to develop a simple EA.

I think that the strategy is "ready". But when I run backtest run, no orders are open. I've printed some debug info and the conditions are OK. The error throwed by the OrderSend function is 138.

the code is the following:

RefreshRates();

OrderSend( Symbol(), OP_BUY, Lots, Slippage, Ask, 0.0, 0.0, c , magic_number, 0, Blue);

Can anybody explain me what's wrong?

Thank you all.

ign...

 
ignacio:
Hi!

Well, as you can see, I'm newbie in this forum. I'm Ignacio, from Argentina. And I trying to develop a simple EA.

I think that the strategy is "ready". But when I run backtest run, no orders are open. I've printed some debug info and the conditions are OK. The error throwed by the OrderSend function is 138.

the code is the following:

RefreshRates();

OrderSend( Symbol(), OP_BUY, Lots, Slippage, Ask, 0.0, 0.0, c , magic_number, 0, Blue);

Can anybody explain me what's wrong?

Thank you all.

ign...

Error 138 means there was a requote. Have you tried using a larger pip value for slippage, something like between 3 and 5?

 

I think there is no such a thing as requote in backtest. The problem, for my opinion, is happening because of the "RefreshRates" that maybe in backtesting can cause a requote problem. Consider this

if (!isTesting()) RefreshRates();

 

Thank you for your responses,

Maji, i've tested some values of slippage in a loop and OrderSend gives me the same error.

elihayun, I have right added your condition and still the same error.

I made many tests and no good results

Any suggestion? I really want to finnish this one to do another EA more serious hehee.

Thank you all

ign...

 

First, in order to get the error description do the following

after the #property link add the line

#property link "http://www.elihayun.com"

#include

now to check the error do this

int err = GetLastError();

if (err != 0)

{

Print("Error # ", err, " ", ErrorDescription(err));

}

For your problem, I cannot think of another problem. Maybe u are using another RefreshRates() Try to comment them out

// RefreshRates()

 
elihayun:
First, in order to get the error description do the following

after the #property link add the line

#property link "http://www.elihayun.com"

#include

now to check the error do this

int err = GetLastError();

if (err != 0)

{

Print("Error # ", err, " ", ErrorDescription(err));

}[/PHP]

For your problem, I cannot think of another problem. Maybe u are using another RefreshRates() Try to comment them out

// RefreshRates()

Here is the out of script:

2006.07.02 11:07:15 2006.01.04 12:00 eaButler EURUSD,H4: Error Description [#138]: requote

2006.07.02 11:07:15 2006.01.04 12:00 stdlib EURUSD,H4: loaded successfully

and here is the code:

[PHP]

last_ticket = OrderSend( Symbol(), OP_SELL, Lots, Slippage, Bid, 0.0, 0.0, c , magic_number, 0, Red);

if(last_ticket < 0)

{

rv = GetLastError();

Print("Error Description [#"+ rv + "]: " + ErrorDescription(rv));

}

Reason: