Help with special order entry in MQL4

Moderator: moderators

RunnrX
rank: <50 posts
rank: <50 posts
Posts: 5
Joined: Fri Jul 08, 2011 12:53 am
Reputation: 0
Gender: Male

Help with special order entry in MQL4

Postby RunnrX » Thu Sep 15, 2011 3:09 am

Hi everyone,

I'm hoping someone on here with some MT4 / MQL4 experience can help me out with an answer to this:

I'm trying to make an EA that opens a position when price breaks above the previous bar's high, but I don't want to use market orders because of the massive slippage you can get at times

I was hoping to program my EA to set Buy Limit entries at 2 pips above the high of the bar, while the Ask of the pair is still below that entry level, so that I would get instant entry like a market order but my price would be no higher than what I specify, like in a limit order.

In other trading platforms like MB Dekstop Pro putting a limit entry at above ask will get you this result, but MT4 just rejects the order if you do a limit above ask --- so is anyone aware of a way to use MQL4 to program an order with such a result?

Thanks!

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
forexjake80
rank: 50+ posts
rank: 50+ posts
Posts: 137
Joined: Sun Nov 15, 2009 12:20 pm
Reputation: 0
Gender: Male

Postby forexjake80 » Fri Sep 16, 2011 10:38 pm

there are differences when you use mbt mt4 did you check those?
It's time to kick ass and chew bubble gum. And I'm all out of gum.

MrPip
rank: <50 posts
rank: <50 posts
Posts: 6
Joined: Sat Jun 07, 2008 10:06 am
Reputation: 0
Gender: Male

Postby MrPip » Sat Sep 17, 2011 9:20 am

Most MT4 brokers require stop and limit orders to be a minimum distance from the current bid or ask. I suspect that is why your orders are being rejected. Try using a larger value for the breakout.

User avatar
forexjake80
rank: 50+ posts
rank: 50+ posts
Posts: 137
Joined: Sun Nov 15, 2009 12:20 pm
Reputation: 0
Gender: Male

Postby forexjake80 » Sat Sep 17, 2011 9:26 am

well, mbt doesnt!
It's time to kick ass and chew bubble gum. And I'm all out of gum.

MrPip
rank: <50 posts
rank: <50 posts
Posts: 6
Joined: Sat Jun 07, 2008 10:06 am
Reputation: 0
Gender: Male

Postby MrPip » Sat Sep 17, 2011 9:39 am

Then try using BUY_STOP instead of BUY_LIMIT.
I have written scripts to scale in to trades that work just fine, placing an initial order and up to 5 more using different pip intervals above for buy or below for sell.

Robert

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

RunnrX
rank: <50 posts
rank: <50 posts
Posts: 5
Joined: Fri Jul 08, 2011 12:53 am
Reputation: 0
Gender: Male

Postby RunnrX » Mon Sep 19, 2011 4:13 pm

The buy stop is ok for half of what I want to do, but it's still missing the aspect that says "I'll pay this much for it and no more". The buy stop still gets me market price instead of what I say I'll get in at, so I slip a few pips each time.

I just liked how in MBT Desktop Pro you could make a limit order above ask, so you'd get filled as fast as a market but never higher than you say you'll pay. I would love to get that going in MT4 but it isn't lookingl likely

User avatar
forexjake80
rank: 50+ posts
rank: 50+ posts
Posts: 137
Joined: Sun Nov 15, 2009 12:20 pm
Reputation: 0
Gender: Male

Postby forexjake80 » Mon Sep 19, 2011 5:03 pm

runnr, please answer my question: did you read the mb trading faq´s concerning their mt4 platform?
It's time to kick ass and chew bubble gum. And I'm all out of gum.

RunnrX
rank: <50 posts
rank: <50 posts
Posts: 5
Joined: Fri Jul 08, 2011 12:53 am
Reputation: 0
Gender: Male

Postby RunnrX » Tue Sep 20, 2011 1:47 pm

forexjake80 wrote:runnr, please answer my question: did you read the mb trading faq´s concerning their mt4 platform?


I didn't read their FAQ but I did talk to a chat representative from MBT/mt4 and they confirmed that while MB Desktop Pro lets you enter buy limits at above the Ask so you get instant fill but at a limited price, MT4 doesn't have any order type like that. They told me that it might be possible to program it in MQL4 and to ask their forum users, and so I posted the question on the MB forum and on the Kreslik ones because I know a lot of experienced users are on here.

Thanks

User avatar
forexjake80
rank: 50+ posts
rank: 50+ posts
Posts: 137
Joined: Sun Nov 15, 2009 12:20 pm
Reputation: 0
Gender: Male

Postby forexjake80 » Tue Sep 20, 2011 2:26 pm

You do not need experienced users! You only need to read the faq´s !
It's time to kick ass and chew bubble gum. And I'm all out of gum.

RunnrX
rank: <50 posts
rank: <50 posts
Posts: 5
Joined: Fri Jul 08, 2011 12:53 am
Reputation: 0
Gender: Male

Postby RunnrX » Tue Sep 20, 2011 2:35 pm

forexjake80 wrote:You do not need experienced users! You only need to read the faq´s !


Well, thanks for stepping up to offer all that help


anyway, to anyone else who can offer anything constructive, I've read through all the MQL4 documentation to get familiar with it so I'm able to code just about anything now, but I wrote on this forum to see if anyone could help contribute any tips toward the coding logic required to execute orders like I mentioned above.

lol and instead of getting that I have a guy named jake telling me to read faqs -- when the MBT chat representative themselves told me that it wasn't a part of MT4 and I should consult the forums for MQL4 coding advice

good night everybody! I'm done with this thread - thanks Jake

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “MetaTrader”