Hodnocení: Empty Star Empty Star Empty Star Empty Star Empty Star
Help with OrderSend( ) Function

Členem od Jan 04, 2011  2 zpráv(a,y) JohnAdams Jan 04 2011 at 01:50
New to mql4, I wrote the following code for practice, but can't figure out why I get an Error 130

I think it has to do with unNormalized numbers. I'm using IBFX broker and they use the 5th decimal on the price.

double Stoploss = 50;
double Takeprofit = 50;

int start()
int ticket = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-Stoploss*Point,
Ask+Takeprofit*Point,'Order #1',1234,0,Red);

if(ticket == -1) Print('error-',GetLastError());


I also tried setting SL and TP to 500 because of the 5th decimal but got the same error. Any suggestions? Thanks


Členem od Aug 20, 2009  202 zpráv(a,y) kennyhubbard (compuforexpamm) Jan 04 2011 at 02:58 (editováno Jan 04 2011 at 03:04 )
double Stoploss = 50;
double Takeprofit = 50;

int start()
int ticket = OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,'Order #1',1234,0,Red);

if(ticket == -1) Print('error-',GetLastError());
else OrderModify(ticket,OrderOpenPrice(),Ask-50*Point*10,Ask+50*Point*10,CLR_NONE);

You are probably dealing with a market execution broker(I don't use IBFX, so I am not sure). That means that you can only enter a stoploss & takeprofit AFTER they return a trade to you. This is simply because you do not know what price you will recieve from them......with market execution your slippage is unlimited.....you takes what you get.

As an en exercise try replacing your ordersend with this 'priceless' order........

int ticket = OrderSend(Symbol(),OP_BUY,1.0,0,0,0,0,'Order #1',1234,0,Red);

It still comes back with a price, meaning that asking price & slippage are ignored. The reason for this is simple, it is not used by the broker at all.....as I said, you take what you get. The reason it still exists is because metaquotes could not remove it from the code without causing massive incompatibilities with our instant execution bokers.

That said, I always still use the correct bid and ask prices for backwards compatibility with the instant execution brokers.

As far as normalising prices go, people tend to go overboard with this......stops do not need to be need to be normalised but I do it anyway as a good practice. When you have a problem caused by unnormalised doubles and price, you will get an error 129 which is invalid price rather than error 130 which is an incorrectly calculated stop. I don't think I have seen an error 129 since I gave up the instant execution brokers.

In terms of your 5 digit broker, you should use Point*10 since the code does not care about the 5 digits.....it simply has recalculated your stops as 5 pips instead of 50 pips. It is good practice to define your pips sizes in the init() function of your EA, so you would have variable 'Pip' declared at the start(global scope) of the EA and then assign it a value in your init() function like this :-

Pip = Point * 10;

Then when you want to turn your 'human pip' stops into 'computer pips' you simply say :-

double Stoploss = 50;
Stoploss = Stoploss * Pip;

Anyway, hope it helps.

Wealth Creation Through Technology

Členem od Jan 04, 2011  2 zpráv(a,y) JohnAdams Jan 04 2011 at 03:29
Thanks for the input.. sounds like you know what you're doing.. I'll give it a try tonight

Just curious.. why did you give up on instant execution brokers?

Thanks again


Členem od Aug 20, 2009  202 zpráv(a,y) kennyhubbard (compuforexpamm) Jan 04 2011 at 03:47
Hi John,

I do mainly asian scalping and I have found that the filtered price feed from instant execution brokers don't work so well. Maybe that has changed in the last year or so but I have found a couple of market execution brokers that work well and I have never felt the need to look back.

The price feed from STP/ECN brokers tend to be more 'raw' and scalpers like this. If you have any doubts about the levels of filtering, have a look at what happens to price feeds at rollover time(5pm EST) and you will get the picture. Compare that with a broker like Jade where you can experience rollover spikes of up to 160 pips(EURCHF once). MB Trading actually disconnect for up to 10 minutes over this period which used to piss me off no end until I eventually understood that this is in my best interest.

Anyway, bottomline is that the spikiness is the benefit and the rollover spikes are the risk. You don't get either at an instant execution broker and nor do you get the profits.


Wealth Creation Through Technology
Prosím, přihlašte se pro vložení komentáře.
Consumer Price Index (11 min)
SEB: EUR/USD sellers at dynamic resistan...(8 min ago)
EURUSD 1.06798 GBPUSD 1.48766
USDJPY 119.644 USDCAD 1.22608
Tools Komunita Zhodnocení Platforma Company Podpora
Ekonomický kalendář Komunita Brokeři Widgety O FAQ
Forex Market Systémy EA systémy Vlastnosti Blog Nápověda
Forex Volatility Most Popular Systems Poskytovatel signálů API Twitter Kontaktujte nás
Forex Correlation Strategie VPS Services Mobile Facebook Nahlásit chybu!
Forex Broker Spreads Soutěže EA Programming Překlady    
Forex Broker Quotes Forex Charts PAMM Brokers RSS    
Forex Broker Swaps Společný přehled Rebate Programs      
Streaming Forex News   Trading Platforms      
Forex Broker Volume          
COT Data          
Forex Calculators          
Forex Heat Map New          

Download Myfxbook Android App
Mapa stránek  |   Terms & Conditions  |   Privacy Policy
©2014 Myfxbook Ltd. All Rights Reserved.
HIGH RISK WARNING: Foreign exchange trading carries a high level of risk that may not be suitable for all investors. Leverage creates additional risk and loss exposure. Before you decide to trade foreign exchange, carefully consider your investment objectives, experience level, and risk tolerance. You could lose some or all of your initial investment; do not invest money that you cannot afford to lose. Educate yourself on the risks associated with foreign exchange trading, and seek advice from an independent financial or tax advisor if you have any questions. Any data and information is provided 'as is' solely for informational purposes, and is not intended for trading purposes or advice.