MetaTrader Experts and Indicators yahoogroups FAQ
Last update January 13, 2007

First things first.  Scripts, Indicators Experts and more is archived at http://www.lightpatch.com/forex/


How to apply experts and indicators and make them work?
 ===========================================

 If it's an expert, you place it in the experts folder of Metatrader.
C:\program files\metatrader\experts

Indicators go to
C:\program files\metatrader\experts\indicators

After you place the file in the appropriate directory, open it with MetaEditor. 
MT4 you should use MT4 version of MedaEditor, and MT3 you should use the MT3 version. 
Hit the enter key 4 or 5 times and then hit backspace the same number of times and then hit
compile for MT4 and MT3 is a file check.  This will compile the expert or indicator and produce
an .ex4 file for MT4 and an .exp file for MT3. Run Metatrader and open an account. 

Close the charts or currency pair that start up with the
initial start up of the program and then open the currency pair that you would like to trade. 

You then should select the time frame of the charts.  Then go to the Navigaor and click on Expert Advisors.
The expert, if loaded in the correct location will be there.  Drag it to the chart and let it go. 

Click on Allow Live Trading and click ok.  The expert should run.  For indicators, do the same as about,
except in the Navigator, click on Custom Indicators. Look for the indicator that you want and drag it and
let it go on the chart. 

Click on Ok and the indicator should function.
Right click in the Market Watch window. In the drop down menu, click on 'Show All Symbols.'

This gives me 18 pairs. If 'Auto Arrange' is unticked, you can rearrange the order of pairs by dragging.


 I can't get the attachment, all it says is 'Attachment not stored' - Help!"
 =====================================================
To receive attachments you need to receive "Individual e-mails" ,

click on "Edit Membership"

scroll down until you see

Message Delivery

Individual emails -
Daily digest -
Special notices -
No email -

Select 'Individual emails' and save changes .



Posting hints that will make everyone's experience better
===========================================

Type a descriptive Subject line for your postings.

"Help" or "I have a question" are not descriptive.

"Trailing stop loss is not closing my trades"
or
"Who has results of testing e.3.02 as of 10/31/05?" are descriptive.

This makes managing the large volume of messages in this group easier.

Don't clutter the message queue with "Thank you" notes.
In most cases a private email to the person is more appropriate.


I am a newbie...
============
Please don't use this as an excuse to be rude.

You're in a group that uses MetaTrader. At least TRY to read the
last months worth of messages BEFORE asking what MetaTrader is.

You're in a group that trades FOREX. At least TRY to understand
what trading and FOREX is, by doing a few Google searches
BEFORE asking what FOREX is or how to trade.

You're in a maze of twisty passages, all alike.
Oops, wrong game :)

AND...

Newbies ought to take a look at these materials and at least be aware they exist.
Know what your Broker should know:
http://www.nfa.futures.org/compliance/forex.asp
Retail FOREX Transactions: A Regulatory Guide:
http://www.nfa.futures.org/compliance/forexRegGuide.asp
NFA fights FOREX fraud:
http://www.nfa.futures.org/news/newsRel.asp?ArticleID=1147

I am not a programmer...
===================
That's not a problem anymore. It's something that 100$ will fix.

Go take a look at Gordago, get the demo, an try it out





Programming hints...
===============
In MetaEditor, should you ever need to know how to use a
specific function, open navigator, select search, then type in the
function, eg, SendMail()...

Also, you can click on the command You don't even need to hightlight it.
Then press F1.

MetaTrader MQL-4 Programming Reference Manual can be found at
http://www.fengshui-123.com/viewthread.php?tid=17849


------------------
I seem to have found a bug in MT4 operator precedence - specifically that
boolean operators don't seem to have the normal precedence found in
virtually every other language. I was writing a 'Trading Time' indicator -
one that would display whether a section of chart lay within the time I
could be at the screen or not, and found that in attempting to use '&&'
and '||' that '&&' doesn't bind tighter than '||' as expected.

I had to put parentheses around the '&&' arguments to make it all work
properly.

i.e.

if (A || C && D){
DoStuff();
}

had to be

if (A || (C && D)){
DoStuff();
}

This is definitely _non-standard_! C++ programmers will get caught by this
as I was, since MQL4 looks so much like C.

------------------




Where do I find a Broker
===================
Admiral Investments and Securities Ltd. http://www.forextrade.ru
Alpari Ltd. http://www.alpari-idc.com
APEX FX Trading http://www.apexfxtrading.com
Bull Trend Brokerage http://www.bulltrend-bg.com
FiboGroup http://www.fibogroup.com
EuroForex Development LLC. http://www.euroforex.net
fxTeam http://www.fxteam.ru/
Financial Network Worldwide Ltd. http://www.forexservice.net
FinMarket Ltd. http://www.finmarket.com.ua
Forex Global Investment LLC http://www.forexgi.com
Forex Ltd. http://www.forexua.com
FX-Pro Ltd. http://www.fx-pro.com
IC Vector Securities Ltd. http://www.icvector.ru
Inforex Introducing Broker http://www.inforex.org
Integral Bank http://www.fxintegral.com.ua
Interbank FX http://www.interbankfx.com
Jaguars Investment LLC http://www.jaguarsinvestment.com
Joy Financial Group http://www.joyfg.com
KVB Kunlun New Zealand Limited http://www.kvbkunlun.com
Lefco Bank http://www.lefco.ru
Livingston Investment Inc. http://www.mytrustbank.com
Man Financial (S) Pte Ltd http://www.manfinancial.com.sg
MIG Investments Group LLC http://www.miginvest.com
Orion Global Financial Services http://www.orionbrokers.com
Performance Forex GmbH http://www.eforex-asia.com
Real Trade Ltd. http://www.realtrade.lv
STS Finance SC http://www.finance.sts.bg
Teletrade D.J. International Consulting Ltd. http://www.teletrade.ru
The Commercial Group http://www.cgtim.com
TradeFXDirect.com, Inc. http://www.tradefxdirect.com
Ukrsotsbank http://forex.ukrsotsbank.com
Windsor Brokers Ltd. http://www.windsorbrokers.biz
X-Trade Sp. z o.o. http://www.x-trade.biz
FXBest http://www.fxbest.ru
ManFinancial http://www.manfinancial.com.sg/en
SNC investment http://www.sncinvestment.com
FXDirectDealer http://fxdd.com
Neurex http://www.neurex.de
NorthFinance http://www.northfinance.com
Admiral Investments and Securities Ltd. http://www.forextrade.ru/
Alpari Ltd. http://www.alpari-idc.com/
APEX FX Trading http://www.apexfxtrading.com/
Bull Trend Brokerage http://www.bulltrend-bg.com/
FiboGroup http://www.fibogroup.com/
EuroForex Development LLC. http://www.euroforex.net/
fxTeam http://www.fxteam.ru/
Financial Network Worldwide Ltd. http://www.forexservice.net/
FinMarket Ltd. http://www.finmarket.com.ua/
Forex Global Investment LLC http://www.forexgi.com/
Forex Ltd. http://www.forexua.com/
FX-Pro Ltd. http://www.fx-pro.com/
IC Vector Securities Ltd. http://www.icvector.ru/
Inforex Introducing Broker http://www.inforex.org/
Integral Bank http://www.fxintegral.com.ua/
Interbank FX http://www.interbankfx.com/
Jaguars Investment LLC http://www.jaguarsinvestment.com/
Joy Financial Group http://www.joyfg.com/
KVB Kunlun New Zealand Limited http://www.kvbkunlun.com/
Lefco Bank http://www.lefco.ru/
Livingston Investment Inc. http://www.mytrustbank.com/
Man Financial (S) Pte Ltd http://www.manfinancial.com.sg/
MIG Investments Group LLC http://www.miginvest.com/
Orion Global Financial Services http://www.orionbrokers.com/
Performance Forex GmbH http://www.eforex-asia.com/
Real Trade Ltd. http://www.realtrade.lv/
STS Finance SC http://www.finance.sts.bg/
Teletrade D.J. International Consulting Ltd. http://www.teletrade.ru/
The Commercial Group http://www.cgtim.com/
TradeFXDirect.com, Inc. http://www.tradefxdirect.com/
Ukrsotsbank http://forex.ukrsotsbank.com/
Windsor Brokers Ltd. http://www.windsorbrokers.biz/
X-Trade Sp. z o.o. http://www.x-trade.biz/
FXBest http://www.fxbest.ru/
ManFinancial http://www.manfinancial.com.sg/en/
SNC investment http://www.sncinvestment.com/
FXDirectDealer http://fxdd.com/
Neurex http://www.neurex.de/
North Finance http://www.northfinance.com/
Forex Service http://www.forexservice.net/
N Two Bank http://www.n2bank.com/
Velocity 4X http://www.velocity4x.com/
Crown Forex http://www.crownforex.com/
Tradex Swiss AG http://www.tradexfx.com/web/index.php?pid=1
Alpha Capital Markets http://www.alphacapitalmarkets.com/main.jsp
Strategy Builder FX http://www.strategybuilderfx.com/


What is Slippage?
==============
The slippage field in an expert market order command specifies a range of
prices above and below the current price at which you are willing to accept
a fill. If you are placing an order at market (buy, sell, or close) and
the slippage field is 2 pips and market price is 1.000, then you are
willing to accept the fill at any price from 0.998 to 1.002.

FXDD however does not use the slippage field when processing expert
order commands on live accounts. With FXDD the market price at the time
when the server processes your order command must exactly match the market
price when your expert sent the order command. If the price has moved by
even 1 pip then FXDD will not fill the order and you will receive an error
message similar to: order failed [price is changed].

Some brokers such as IBFX will issue an automatic requote and automatic
fill at the requoted price if the market price is within the range specified
by the slippage field in the expert order command. Brokers can also set their
server to automatically fill the order without the requote as long as the price
is within the range specified by the slippage field.

FXDD can be very frustrating if your script requires opening or closing a
lot of trades quickly at market price.





Where do I find...
=============
You're probably looking for an expert that someone said makes a lot of money
or perhaps that last indicator to add to the seven alerady on your chart
and you need it NOW not later.

http://groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/
or
http://www.lightpatch.com/forex/



How to do Alerts and Email
====================
I see a lot of people here asking to add alarm when an indicator is light up.
Especially when a arrow/bullet is turn on.

Actually, it is very simple task. All you have to do is follow the following instructions.

1) Every indicator has an indicator array that keep the values of the indicator.
Values can be 0 or not 0. To find out the indicator name look for the command:
SetIndexBuffer
In the indicator editor it should look like this

SetIndexBuffer(0,ExtMapBuffer);
SetIndexBuffer(1,ExtMapBuffer2);

This lines tell us that we have 2 indicator buffers

2) Look when the indicator buffer change its value.
In the example above we will look to line that contains the following patter:
ExtMapBuffer[number] = where number can be a figure or a name.
For example: if(res!=0.0) ExtMapBuffer[shift]=res;
if after the equal sign there is 0 do nothing.

3) Change it to make an alarm.
After finding the value setting line we will add an alarm to it.
a) add { before the setting. In the example above :
if(res!=0.0) {ExtMapBuffer[shift]=res;
b) add the Alert command after the ;. In the example above:
if(res!=0.0) { ExtMapBuffer[shift]=res;
Alert("Indicator set");
}
Do not forget to close the }

4) repeat for every buffer value setting

Compile and you have an indicator with alert

Hope it will help you

--------------------------------
Could anyone help with a profit alarm/alert e.g one is long both
NZD/USD and USD/JPY, it is possible to receive a SMS or alert say when
total profit is say 20 or -50. Thanks

for(cnt=0;cnt=(20*Point)) {
Alert(OrderSymbol()+" is in profit by 20 pips.");
SendMail(OrderSymbol(),"20 pip profit target has been reached"); }
if(OrderOpenPrice()-Bid>=(50*Point)) {
Alert(OrderSymbol()+" is in loss by 50 pips.");
SendMail(OrderSymbol(),"is in a 50 pip loss"); }

Note: in meta editor, should you ever need to know how to use a
specific function, open navigator, select search, then type in the
function, eg, SendMail()...
Note2:Click on the command. You don't even need to hightlight it.
Then press F1.


void SendMail( string subject, string some_text)

Sends mail to address set in the Tools->Options->EMail tab if enabled.
Note: Posting e-mail can be denied or address can be empty.

Parameters

subject - Subject text.
some_text - Mail body.

Sample

double lastclose=Close[0];
if(lastclose<my_signal)
SendMail("from your expert", "Price dropped down to "+DoubleToStr(lastclose));





How can I tell when there is a new Bar
=============================
from metaquotes site:

The third method is based on the time a bar is opened:

static datetime prevtime=0;
...
if(prevtime == Time[0]) return(0);
prevtime = Time[0];
...

It is the most reliable method. It works in all cases.





Can someone de-compile an EXP or EX4 file for me?
=======================================
Subject: EA Decompiler
Here is the response I got back from the guy in Russia.

Hi.

Decompiling of one EXP-file costs $10 USD.
Removal of restrictions from one EX4-file costs $10 USD.
Because recovery of a human readable MQ4 file is a difficult
problem therefore decompiling of one EX4-file costs $50 USD.
I accept paypal too.

Regards

His email is e x p t o m q l @ h o t m a i l . c o m






Copyrights?
=========
Good grief. Where on earth did you obtain such a lack of
understanding of copyright law? For the record (however, it should
be obvious) you CANNOT simply make any change to someone else's work
and call it your own. That would be a derivative work and--unless
you obtained permission from the copyright owner--would be a case of
copyright infringement. In the United States, the creator of a work
(e.g. a computer program) is assumed to have copyright rights to a
work--even if the work is not formally copyrighted and had a copy
place in the Library of Congress.


This sort of 'help' from the willfully ignorant is why the Internet
is a curse as well as a blessing. When in doubt: please keep your
mouth shut.


See http://www.copyright.gov/ for the FACTS.


See also http://www.uspto.gov/ to dispell myths regarding
trademarks, registered trademarks, and patents (no, regardless of
what people of Oba's ilk might say, they're not the same thing).


- Patents & trade secrets protect ideas.
- Trademarks protect names.
- Copyrights protect works.





Coding helps and hints
=================
The MT4 language is based on C so that is the language you'd want to study.
General programming concepts:
http://www.play-hookey.com/computers/programming.html

C basics:
http://cplus.about.com/od/beginnerctutoria1/l/blctut.htm

Another C basics site:
http://www.scit.wlv.ac.uk/cbook/


PLEASE PLEASE PLEASE Use descriptive names for all variables and procedures.

b1, gle, eres, TSL and d are NOT descriptive!

BuyTicket1, ErrorVal, ReturnVal, CurrentStopLoss, and BBandWidth ARE descriptive.

a single function for checking signals..
a single function for opening orders...
a single function for closing orders..
a single function for trailing stops..
a single function for moving s/l to break even...


Array Declarations
===============
Thankyou to everyone who have contributed answers to my question. With
your help I now understand the Arrays within Metatrader well enough to
get on with my indicators.
For anyone else that has the same question, here is a summary of how
to get non buffer arrays to work in MT. (Non buffer arrays are the non
screen buffer or indicator Arrays).
Screen buffer arrays are initialized automatically because of the
SetIndexBuffer command. There can be a maximum of only 8 of these.
To have other arrays operate in the same way you need the following,
all within the start function and not before it:
1. Declare the array
eg: double Array1[];
2. Declare Size of Arrays
eg: ArrayResize(Array1,limit);
(If you are using a variable for the array size,
make sure it is set before you try to declare the array size.)
3) Change Array to same sort of series Array as screen buffers
ie: This is the order that the array is filled
last -> first or first -> last
eg: ArraySetAsSeries(Array1,true);

I have a really basic working example below. Obviously once you have
created the array, you can now perform other functions on it in
putting it into the screen buffer:
eg: ExtMapBuffer1[i] = iMAOnArray(Array1,limit,13,8,MODE_EMA,i)

Hope this makes it clearer for anyone who has the same frustrations as
I had. Happy trading!

and from Robert...

Just answered my own question. You declare the arrays outside
of the start function, so no potential stack overflow.

What about buying and selling and chart prices ?
=====================================
Because on a sell trade the spread is paid on exit.
So increasing the spread is a way for the broker to
make more money on sell trades. They take a portion
of what would have been a win or give you a loss
when it might have become a win by not hitting your
stop loss under normal spread conditions.

This is common when there is a head fake before a new
short term trend occurs. Also can happen when there is
a small retrace. The spread increase can turn a small
retrace into a larger retrace. And this is something
that will not show up on the chart based on the bid.


How does one convert a indicator into a expert ?
====================================

Not necessarily easy -- first you have to make definitive rules for how
you trade the indicator (or what you want the expert to do or output), then
either call the indicator from your expert (meaning that the indicator must
be present in the indicator folder for the expert to work properly) or else
incorporate the code from the indicator into your expert. Then you use a
series of If, while, and for loops to compare current price with the value
of the indicators and place, close, or modify orders, send emails, alerts,
write comments, draw lines accordingly.

An indicator is a passive reporting of the market, it doesn't care whether
you color it green, red, orange, black, blue.... It doesn't judge whether
the market is oversold, overbought, trending, ranging, etc. It just draws
something on a chart based on some mathematical operation on current and
historical prices.

EA's take action -- can be as simple as drawing a line, making a sound,
sending an alert, or as complicated as managing a grid of buys and sells
with varying sl's tp's lotsizes, etc. and monitoring (specific events in)
hundreds of indicators from different timeframes, different pairs,
different criteria, etc, posting account statements to ftp servers every
five minutes.

Sunday Checklist for Demo EA's
=========================
Is it running in time for the 1st tick of the week?

Have any needed files been updated?

Are times correct for DST/non-DST?

Is lot size correct?

Will 30-day account be live for entire week?

Checked Mailbox for anything unusual in coming week?

Are 2 boxes un-checked at Tools/Options/EAs/Disable experts when…?