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 Apr 27, 2024 12:18 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Calculate Open Positions by MQL icon
PostPosted: Tue Jun 10, 2014 1:30 am 
Offline

Joined: Thu Oct 27, 2011 12:41 pm
Posts: 59
Hi there,

Supposed I have EA for EurUsd, GbpUsd and NzdUsd. They are attached to their own chart respectively. Supposed due to co-relation issues I want the other two to NOT trade when a position by any one is entered. I was told to use 'CalculateOpenPosition' by the MQL icon.

How is this done?
Any diagrams to show?


Top
 Profile  
 
 Post subject: Re: Calculate Open Positions by MQL icon
PostPosted: Tue Jun 10, 2014 11:37 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
If you want to use MQL you need to open a generated ea with MetaEditor and understand how it works
From a generated EA I got this:
if (CalculateOpenPositions(symbol_bn,ordertype_bn,magic_bn)>=MaxNumberofPositions) {
Print("I-Warning : Can not execute new ",OrderTypetoString(ordertype_bn)," order for Symbol ",symbol_bn,". Maximum number of ",MaxNumberofPositions," open positions reached.");
return(0);
}

In the MQL icon in version 3.2 or higher (won't work in old versions) you need to put something like:
CalculateOpenPositions(symbol_bn,ordertype_bn,magic_bn)>=MaxNumberofPositions

You need to replace symbol_bn,ordertype_bn,magic_bn and MaxNumberofPositions with your own info
Like CalculateOpenPositions("EURUSD",OP_BUY,your ea magic number)>=1

unfortunately we do not do MQL support here or teach MQL - we only do product support so you have to do a lot of try and error on your end.

We do not have any examples but I have seen some posts in the forum with some MQL code


Top
 Profile  
 
 Post subject: Re: Calculate Open Positions by MQL icon
PostPosted: Wed Jun 11, 2014 6:31 am 
Offline

Joined: Thu Oct 27, 2011 12:41 pm
Posts: 59
I have this question.

symbol_bn may refer to EURUSD if I have one EA only. But if I have many EAs for pairs ending with USD do I define them all or is there a shorter way like xxxUSD?


Top
 Profile  
 
 Post subject: Re: Calculate Open Positions by MQL icon
PostPosted: Thu Jun 12, 2014 10:29 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Unfortunately if you want to use the MQL icon you need to understand MQL a bit
If you want to check 2 pairs, you need to use an AND

CalculateOpenPositions("EURUSD",OP_BUY,your ea magic number)>=1 && CalculateOpenPositions("GBPUSD",OP_BUY,your ea magic number)>=1


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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