Download MetaTrader 5

Experts: MACD Sample EA Updated

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
188990
MetaQuotes Software Corp.  

MACD Sample EA Updated:

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.

Author: Brian Dee - Random Trader

Brian Dee - Random Trader
1760
Brian Dee - Random Trader  

Wait for next version 452

Bug fixed where MagicNumber not being used in OrderClose :(

Some small performance changes
whroeder1
16278
whroeder1  
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
6398
Tjipke de Vries  

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
235
noonehastherighttojudgeanother  

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
15
redzpe  

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
28
EA  
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
To add comments, please log in or register