molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Sat May 11, 2024 12:39 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Using both OrderSelect() and OrderProfit in an MQL block
PostPosted: Mon May 21, 2012 9:54 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Hello Support,

I'm trying to use the MQL Block to close positions based on OrderProfit() MagicNumberLong and MagicNumberShort, using the following:

Image

Is there any reason why this is not working?

The Order Number itself is correct -
The OrderSelect function seems right -
The OrderProfit function seems right -

The trading condition tests "OK" and the EA does build without errors.

Image


The EA also runs, but it won't close the current order given its correct MagicNumberLong/MagicNumberShort at the designated OrderProfit() level, even though the trade runs well beyond the OrderProfit() amount.

Thanks!
cfx


Top
 Profile  
 
 Post subject: Re: Using both OrderSelect() and OrderProfit in an MQL block
PostPosted: Mon May 21, 2012 10:22 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Also, I tried OrderSelect(4167090, SELECT_BY_TICKET) == true, which had no positive effect on the outcome.

Thanks,
cfx


Top
 Profile  
 
 Post subject: Re: Using both OrderSelect() and OrderProfit in an MQL block
PostPosted: Tue May 22, 2012 9:26 am 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
Order management is a bit more complex than that. Ideally you want to go over all orders. You cannot use the ticket id because you don't know it, using the magic number does not make sense. Try using SELECT_BY_POS and 0 but again it is more complex. We plan to have some features like the one you want for the next release late this year.


Top
 Profile  
 
 Post subject: Re: Using both OrderSelect() and OrderProfit in an MQL block
PostPosted: Tue May 22, 2012 10:18 am 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
The first pic shows that SELECT_BY_POS was used first with no positive results.

I have not tried using "0" as I only found documentation on codebase relative to POS and TICKET. There is also no clear mention in any MQL documentation that I have seen, that distinguishes Magic Number from Order Number. The only thing one learning MQL can do is glean that they are one and the same.

So, now - here comes the question:

Is Magic Number the same thing as the Order Number?

(that's why I used the MagicNumberLong/MagicNumberShort) in the OrderSelect function by the way)

Yes, Closing of positions using something other than a Stop or Limit order, would be a great product enhancement.

Thanks,
cfx


Top
 Profile  
 
 Post subject: Re: Using both OrderSelect() and OrderProfit in an MQL block
PostPosted: Tue May 22, 2012 10:06 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Quote:
Is Magic Number the same thing as the Order Number?

No.

If you have a pro version look at the code for the function that closes the transactions, it shows how to go over the transactions. The function that counts number of shorts and longs also go over the transactions.


Top
 Profile  
 
 Post subject: Re: Using both OrderSelect() and OrderProfit in an MQL block
PostPosted: Wed May 23, 2012 11:40 am 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
molanisfx wrote:
Quote:
Is Magic Number the same thing as the Order Number?

No.

If you have a pro version look at the code for the function that closes the transactions, it shows how to go over the transactions. The function that counts number of shorts and longs also go over the transactions.


Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009