EA advice

 

Hi there

I am new to MQL4 and am not a programmer by any strecth of the imagination, however I am giving it a go. I have managed to use an MQL4 builder to create the attached strategy, but I have made some changes, the problem is when I run it, it's not doing the right things, but yet sometimes it does. What I mean to say is:

(I have derived this system from a standard bollinger band 20,2,2 set up.)

To buy

When the price is less than the lower band on a setting of 20,2.4,2.4 - BUY

The close

When the price crosses the lower band on a setting of 20,1,1

To sell

When the price is higher than the higher band on a setting of 20,2.4,2.4 - SELL

The close

When the price crosses the higher band on a setting of 20,1,1

This strategy has variables where I can adjust the stop loss but the idea is that it takes only one position until it closes. I would like at a later stage to test to see whether it would be worth scaling in. Is there anyone that is willing to help this novice.

I'd really appreciate any help

Many thanks

Steve

Files:
intradayv2.mq4  10 kb
 
  1. smistretta:

    To buy

    When the price is less than the lower band on a setting of 20,2.4,2.4 - BUY

    The close

    When the price crosses the lower band on a setting of 20,1,1

                         if (CloseBuy1_1 > CloseBuy1_2) Order = SIGNAL_CLOSEBUY;
    You're close criteria is when ask crosses above the upper band.
  2. double Buy1_2 = iCustom(NULL, 0, "Bands2.4", MODE_LOWER, Current + 0);
    
    You're not using iBands on the open, instead custom indicator called with NO parameters, and MODE_LOWER is an invalid buffer index.

  3.    if (EachTickMode && Bars != BarCount) TickCheck = False;
    
    Bars is unreliable (doesn't change once it reaches max bars on chart), Volume is unreliable (can miss ticks) Always use time
    int start(){ static datetime Time0;
       bool newBar = Time0 != Time[0]; Time0 = Time[0];

  4.    for (int i = 0; i < Total; i ++) {
          OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
          if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
    
    You must count down when closing in the presense of multiple orders (multiple charts) No magic number means this EA is incompatable with every other including itself on other charts and manual trading.
        for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
            OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
        &&  OrderMagicNumber()  == magic.number             // my magic number
        &&  OrderSymbol()       == Symbol() ){              // and my pair.
    

  5.               if(Bid - OrderOpenPrice() > Point * TrailingStop) {
    EAs must adjust for 4/5 digit brokers, TP, SL, AND slippage
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

 

Hi WHRoeder,

Thank you for your prompt response. I will work through the suggestions which you have put on here, please bear with me, and lets see what happens. I really appreciate your help, and thank you.

Many thanks

Steve