To use chat, please login.
Back to contacts

Mql4: How close is close enough

FSM (dkilmer)
Jan 13 2017 at 23:36
90 ieraksti
I am programming on MT4 with Mql4

I want to have a limit order placed, and have had issues in the past with setting limits to close to the market and having it rejected with a error code that meant it was to close to market to be a limit order.

Lets say I have the price I want to enter, the current close of the market, and all the other variables. What would I use to see if the desired price is close enough ( or not ) to be a market order versus a limit? Would it be if price was with in the spread, and/or would I also include slippage in that as well?


Any ideas would be greatly appreciated
Everything in the market is like a fart, if you have to force it, it is probably shit
kennyhubbard (compuforexpamm)
Jan 14 2017 at 13:15
265 ieraksti
Check the stop level using MarketInfo(Symbol(),MODE_STOPLEVEL)

Remember to convert it to points.

In my experience, even this can produce an error on exotics that have a large volatile spread. In cases like this i will use something like fmax(spead, Stoplevel).
Wealth Creation Through Technology
FSM (dkilmer)
Jan 20 2017 at 15:37
90 ieraksti
MODE_STOPLEVEL only returns zero on my broker (oanda) . I am just using Spread for now. No errors yet
Everything in the market is like a fart, if you have to force it, it is probably shit
Ivan (StoneHeart)
Jan 20 2017 at 21:39
131 ieraksti
If You have STOPLEVEL=0 , probably this is Real NDD broker.
Orders have to be sent without TP or SL (must be 0.0)
The SPREAD still exist, but You have to be able
to set TP or SL even inside SPREAD, after order is send.
FSM (dkilmer)
Jan 20 2017 at 22:03
90 ieraksti
From the mql4 site:

A zero value of MODE_STOPLEVEL means either absence of any restrictions on the minimal distance for Stop Loss/Take Profit or the fact that a trade server utilizes some external mechanisms for dynamic level control, which cannot be translated in the client terminal. In the second case, GetLastError() can return error 130, because MODE_STOPLEVEL is actually 'floating' here.

I am not having a issue with setting sl/tp . I was trying to find a way to detect when placing a limit would be to close to the actual price, resulting in the need for a market order.

I setup a function to detect with in range, using the appropriate ask/bid + Spread depending on direction. I was just curious if there was anything else I should be looking out for.


Anyways, Thank You :)
Everything in the market is like a fart, if you have to force it, it is probably shit
edward
benchmarkpro
Jan 23 2017 at 03:52
58 ieraksti
My opinion is that limit orders are a crutch for NON-API traders that allows them to place a request with their broker to open or execute a trade at a specific price, etc..

this is a band-aid for non-api traders.

Api traders, on the other hand, do not need limit orders...

Api traders write custom code that will wait patiently for the market price to reach a specific price and then it will open the trade on the fly in real time...

thank you.

Edit: i personally do not set takeprofit and/or stoploss while opening a trade, instead i first open the trade and then i set any desired stop loss or takeprofit...

FSM (dkilmer)
Jan 23 2017 at 06:01
90 ieraksti
Why would it be a crutch if you are doing essentially the same thing anyways.

Sure, noted: I could just set a condition to see when the price gets to my supposed limit order and execute it at market. I have never heard the term 'Api traders' . I am not using any application interfaces, so it can't be that you are talking about. Googling it only brings up the usual suspects ( brokers that offer a api, etc,.... ) .

Also, I don't set stops with the order at the same time either, the broker doesn't allow it,.... why is it worth mentioning this?

Anyways, thanks for the suggestion, even though it isn't related to the topic
Everything in the market is like a fart, if you have to force it, it is probably shit
edward
benchmarkpro
Jan 23 2017 at 06:07
58 ieraksti
kennyhubbard (compuforexpamm)
Jan 23 2017 at 13:40
265 ieraksti
benchmarkpro posted:
My opinion is that limit orders are a crutch for NON-API traders that allows them to place a request with their broker to open or execute a trade at a specific price, etc..

this is a band-aid for non-api traders.

Api traders, on the other hand, do not need limit orders...

Api traders write custom code that will wait patiently for the market price to reach a specific price and then it will open the trade on the fly in real time...

thank you.

Edit: i personally do not set takeprofit and/or stoploss while opening a trade, instead i first open the trade and then i set any desired stop loss or takeprofit...


You need to tell me what broker you use......I have been looking for a broker that gives me the price I execute my trade at.....irrespective of how fast the market is moving, or that beats the Limit Order pricing already sitting on their server.
Wealth Creation Through Technology
Lūdzu ienāciet, lai komentētu.