Download MetaTrader 5
To add comments, please log in or register
Are you a real pro? Share your knowledge with millions of traders!
mar
1143
mar 2014.12.12 09:23 

Hi,

I plot a line into a chart and then I execute a test-script. If the horizontal line is below the price it opens a market buy order and if the line is above the current price a sell market order is placed. Sometimes I get an error #130. I read about it and then I came to the conclusion that this error occurs when the horizontal line is not a multiple of Ticksize. It often happens when I test it with CFDs.

Unfortunately I have no idea how to correct this price. I have done this so far:

if (StopLine % MarketInfo(NULL, MODE_TICKSIZE) != 0) StopLine = ?

 

For example the German DAX: If the StopLine is 9814.32 the error #130 occurs while sending the order because a valid stoploss can only be 9814.00 or 9814.25.

What I also don't understand is that MarketInfo("DAX30", MODE_TICKSIZE) is 0.01 even though the ticks are in 0.25 steps. Or is that just a wrong information or a broker problem? 

Carl Schreiber
5927
Carl Schreiber 2014.12.12 09:52  

1) %-Division is only for integer (int, long, ulong, ..)

2) For double-vars MathMod() does have a problem! You'd better use the this: https://www.mql5.com/en/forum/143605

3) Error 130 in many cases mean the price is too close (check:MODE_FREEZELEVEL & MODE_STOPLEVEL) or on the wrong side.

4) May be you should use the Point? (Point is the unit of price measurement for a symbol (the minimum possible price change, the last significant figure of the price value).)

mar
1143
mar 2014.12.12 10:49  

Thanks, gooly. But unfortunately that doesn't work. I also found some code from WHRoeder and tested that. The problem here is definitely that my broker has false values for CFDs.

The Dax entry or stop price can only be in 0.25 steps but with all the MarketInfo() I can't find out about these steps and therefore I don't know how I can correct these values.

Because my ticksize is 0.01 instead of 0.25 (what it should be), I can't do a calculation based on ticksize.

 

Alain Verleyen
Moderator
28518
Alain Verleyen 2014.12.12 17:04  
mar:

Hi,

I plot a line into a chart and then I execute a test-script. If the horizontal line is below the price it opens a market buy order and if the line is above the current price a sell market order is placed. Sometimes I get an error #130. I read about it and then I came to the conclusion that this error occurs when the horizontal line is not a multiple of Ticksize. It often happens when I test it with CFDs.

Unfortunately I have no idea how to correct this price. I have done this so far:

 

For example the German DAX: If the StopLine is 9814.32 the error #130 occurs while sending the order because a valid stoploss can only be 9814.00 or 9814.25.

What I also don't understand is that MarketInfo("DAX30", MODE_TICKSIZE) is 0.01 even though the ticks are in 0.25 steps. Or is that just a wrong information or a broker problem? 

price=MathRound(price/tickSize)*tickSize
But in your example, it's seems MarketInfo("DAX30", MODE_TICKSIZE) is not reliable. Contact your broker.
Halley
198
Halley 2014.12.13 05:22  
mar:

Thanks, gooly. But unfortunately that doesn't work. I also found some code from WHRoeder and tested that. The problem here is definitely that my broker has false values for CFDs.

The Dax entry or stop price can only be in 0.25 steps but with all the MarketInfo() I can't find out about these steps and therefore I don't know how I can correct these values.

Because my ticksize is 0.01 instead of 0.25 (what it should be), I can't do a calculation based on ticksize.

 

Place a pending order and change its price randomly to find out levels it accepts. I guess it would respect the tick size value from the MQL, whatever the steps seem to be. Though the DAX futures has the tick size of 0.5 point, its CFDs vary, but I have never seen a different value from the point.

Keith Watford
Moderator
7870
Keith Watford 2014.12.13 05:54  
DeepThought:

Place a pending order and change its price randomly to find out levels it accepts. I guess it would respect the tick size value from the MQL, whatever the steps seem to be. Though the DAX futures has the tick size of 0.5 point, its CFDs vary, but I have never seen a different value from the point.

It is impossible that tick size can be 0.5 point. A point is the smallest decimal place.

Ie

if the smallest possible increment is 0.01, the point equals 0.01

0.5 point would be 0.005 and would not be acceptable. 

Halley
198
Halley 2014.12.13 07:52  
GumRai:

It is impossible that tick size can be 0.5 point. A point is the smallest decimal place.

Ie

if the smallest possible increment is 0.01, the point equals 0.01

0.5 point would be 0.005 and would not be acceptable. 

Hello GumRai,

a point is usually meant a price unit in trading futures, like a pip in Forex. A point in Metatrader is unfortunate term confusing the original meaning.

/
To add comments, please log in or register