MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal

Source code library - Expert Advisors, Indicators and Scripts

MetaTrader Market - the place where newest trading robots appear
To post a new code, please log in or register

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2011.05.30 09:09
MACD Sample EA Updated

MACD Sample EA Updated - expert for MetaTrader 4

| English Spanish Portuguese

Views:
7114
Rating:
Files:

The classic MT Sample EA updated for full/sub-pip accounts, also now handles ECN/STP brokers.


Examples of setting trading hours, and added externals for StopLoss, MagicNumber and order comment.


Last comments | Go to discussion (6)
whroeder1
whroeder1 | 30 May 2011 at 18:07
You MUST count down in the presence of multiple orders (multiple charts.)
if (Hour() >= StartHour)
    if ((Hour() <= LastHour)) return (true);
Allow trading over midnight (e.g. 18 .. 02)
    int         DOW = TimeDayOfWeek(now),   /* forum.mql4.com/33851
    // reports DayOfWeek() always returns 5 in the tester. No refresh?*/
                DayMask = 1 << DOW;
    //                      #define DAYS_MAX    0x3F// 1<<6-1=63. (S-F)
    //extern int      Days.Mask               =  55;      // Not Wed
    if (Days.Mask & DayMask == 0){  StrApnd(EA.status," Day=",DOW); return; }
    //extern double   TradeHr.UTC.Start   =   7.3;    // London-1
    //extern double   TradeHr.UTC.End     =  12.9;    // NY open
    int secStart    = 3600*TradeHr.UTC.Start,
        secEnd      = 3600*TradeHr.UTC.End,
        hrBeg       = (now-secStart+86400)%86400,
        hrEnd       = (now-secEnd  +86400)%86400;
    if (hrBeg > hrEnd){ double Tminus=hrBeg/3600.-24;
                StrApnd(EA.status," HR", DoubleToStr(Tminus,2));    return; }
Tjipke de Vries
deVries | 3 Jun 2011 at 23:58

total=OrdersTotal();
if(total<1)

This is your way how you check if you can open an order

What happens when OrdersTotal()>0 there will be no order opened

In back test you see no error

in live trading there can be many other trades not from this EA be open

I helped someone on the Donna Forex Forum with this problem

See http://www.donnaforex.com/forum/index.php?topic=3031.0

This EA is the same idea

noonehastherighttojudgeanother
serpentsnoir | 5 Jun 2011 at 14:55

while you are fixing things...

the buy logic for trailing stop looks like this

                              if(Bid-OrderOpenPrice()>sdPoint*TrailingStop)
                                {
                                 if(OrderStopLoss()<Bid-sdPoint*TrailingStop)

and the same in the sell looks different

                              if((OrderOpenPrice()-Ask)>(sdPoint*TrailingStop))
                                {
                                 if((OrderStopLoss()>(Ask+sdPoint*TrailingStop)) || (OrderStopLoss()==0))

not a big deal, but one of the two should change, thinking it should be the buy logic.

sn

redzpe
redzpe | 4 Jul 2011 at 10:37

Thanks for your fine work with this EA. Everything works fine (and good) for me in backtesting, but it will not make a single trade when I put it to work (Alpari or Forex4yoy demoaccounts). Tried to run it on 5 min. chart just to make shure there is a trigger. Any suggestions?

EA
FSS1 | 18 Jul 2011 at 10:03
vola66:

Thanks for your fine work with this EA. Everything works fine (and good) for me in backtesting, but it will not make a single trade when I put it to work (Alpari or Forex4yoy demoaccounts). Tried to run it on 5 min. chart just to make shure there is a trigger. Any suggestions?


FSS_InDay_EA 2 days Discount - 50 % More info -Best Regard,FSS Team