Forex



Go Back   Forex Trading > Discussion Areas > Setup Questions
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2006, 10:41 PM
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
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
Code:
/
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?

Last edited by cardio; 06-30-2006 at 03:14 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 06-29-2006, 11:37 PM
Senior Member
 
Join Date: Mar 2006
Posts: 793
Maji is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 06-30-2006, 03:16 PM
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 06-30-2006, 03:43 PM
elihayun's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 396
elihayun is on a distinguished road
Quote:
Originally Posted by 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
Code:
/
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 06-30-2006, 05:31 PM
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
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

Code:
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);
            }


}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 07-02-2006, 12:03 AM
Member
 
Join Date: Jun 2006
Location: Buenos Aires
Posts: 55
ignacio is on a distinguished road
Arrow 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:
Code:
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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 07-02-2006, 05:51 AM
Senior Member
 
Join Date: Mar 2006
Posts: 793
Maji is on a distinguished road
Quote:
Originally Posted by 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:
Code:
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 07-02-2006, 06:29 AM
elihayun's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 396
elihayun is on a distinguished road
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();
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 07-02-2006, 02:33 PM
Member
 
Join Date: Jun 2006
Location: Buenos Aires
Posts: 55
ignacio is on a distinguished road
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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 07-02-2006, 03:02 PM
elihayun's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 396
elihayun is on a distinguished road
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 <stdlib.mqh>


now to check the error do this

PHP Code:
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()
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
error 130, http://www.elihayun.com, metatrader error 138, MODE_STOPLEVEL, mt4 error 138, Order Close error 138, order send error 138, OrderClose error 138, OrderSend error 130, OrderSend error 138


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Has anyone got this error? wolfe Metatrader 4 7 03-13-2009 10:40 PM
Error codes script! codersguru Tools and utilities 6 05-03-2008 01:14 AM
need help on codes antone Indicators - Metatrader 4 15 03-01-2007 02:48 PM
Error JoZo General Discussion 2 06-28-2006 08:45 PM
MT4 Indicator codes coming out of my ears! fred Metatrader 4 12 03-20-2006 11:25 AM


All times are GMT. The time now is 11:31 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.