Not logged in
Viewing 2 posts - 1 through 2 (of 2 total)
  • #111962 |
    Customer
    8 Posts

    Hi Support,

     

    I am having a problem my EA to trade on certain days of the week, with the option of turning the day off or on in EA.

     

    However, when I back test in MT4 platform the EA only trades on Mondays and not the rest of the week.

     

    I have set variables as both Boolan and int and tried both options to no avail.

     

    see screen shot attached and strategy (TradeDays On OFF.sqw)

     

    Any Ideas, I am missing something out or perhaps its the order in which the rules should be…

     

    Regards John.

     

     

    //——————————————————————–
    // No Trades Mon

    IF  (IsBarOpen is True) && (((MonTrade = 0)
          And (DayOfWeek[0] = _CONSTANT_)))
    THEN
       // Action #1
          Close all orders;

       // Action #2
       Do Nothing

    END IF;

    //——————————————————————–
    // No Trades Tue

    IF  (IsBarOpen is True) && (((TueTrade = 0)
          And (DayOfWeek[0] = _CONSTANT_)))
    THEN
       // Action #1
          Close all orders;

       // Action #2
       Do Nothing

    END IF;

    //——————————————————————–
    // No Trades Wed

    IF  (IsBarOpen is True) && (((WedTrade = 0)
          And (DayOfWeek[0] = _CONSTANT_)))
    THEN
       // Action #1
          Close all orders;

       // Action #2
       Do Nothing

    END IF;

    //——————————————————————–
    // No Trades Thur

    IF  (IsBarOpen is True) && (((ThuTrade = 0)
          And (DayOfWeek[0] = _CONSTANT_)))
    THEN
       // Action #1
          Close all orders;

       // Action #2
       Do Nothing

    END IF;

    //——————————————————————–
    // No Trades Fri

    IF  (IsBarOpen is True) && (((FriTrade = 0)
          And (DayOfWeek[0] = _CONSTANT_)))
    THEN
       // Action #1
          Close all orders;

       // Action #2
       Do Nothing

    END IF;

    //——————————————————————–
    // No Trades Sat

    IF  (IsBarOpen is True) && (((SatTrade = 0)
          And (DayOfWeek[0] = _CONSTANT_)))
    THEN
       // Action #1
          Close all orders;

       // Action #2
       Do Nothing

    END IF;

    //——————————————————————–
    // EnvUpper Band Short

    IF  (IsBarOpen is True) && (((Bid >= Envelopes( 8 , Exponential , 0 , Median price , 0.12 )[1])
          And ((SpreadInPips < 7)
          And ((DayOfWeek[0] = _CONSTANT_)
          And ((MonTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And ((TueTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And ((WedTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And ((ThuTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And ((FriTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And (SatTrade = 1)))))))))))))))
    THEN
       // Action #1
          Close order with Magic Number: 2000;

       // Action #2
       Sell 0.1 lots at Market
          Magic Number = 1000;
          Stop Loss = 25 pips;
          Profit Target = (Envelopes( 8 , Exponential , 0 , Median price , 0.03 )[1] ? 1 : 0) pips;

       // Action #3
          Draw Down Arrow;

    END IF;

    //——————————————————————–
    // EnvLower Band Long

    IF  (IsBarOpen is True) && (((Ask <= Envelopes( 8 , Exponential , 0 , Median price , 0.12 )[1])
          And ((SpreadInPips < 7)
          And ((DayOfWeek[0] = _CONSTANT_)
          And ((MonTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And ((TueTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And ((WedTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And ((ThuTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And ((FriTrade = 1)
          Or ((DayOfWeek[0] = _CONSTANT_)
          And (SatTrade = 1)))))))))))))))
    THEN
       // Action #1
          Close order with Magic Number: 1000;

       // Action #2
       Buy 0.1 lots at Market
          Magic Number = 2000;
          Stop Loss = 25 pips;
          Profit Target = (Envelopes( 8 , Exponential , 0 , Median price , 0.03 )[1] ? 1 : 0) pips;

       // Action #3
          Draw Up Arrow;

    END IF;
     

    Attachments in this forum are visible only for registered users.
    Attachments in this forum are visible only for registered users.
    #123738
    Mark Fric
    Administrator
    1182 Posts

    Hello,

     

    one problem I see is that there and / or conditions are not properly bracketed. 

    You should add brackets to properly group “and” and “or” conditions, otherwise they will be evaluated one by one, which will have very unexpected results.

     

    You can set brackets in c IF panel, see the screenshot.

     

     

     

    Attachments in this forum are visible only for registered users.

    Mark
    StrategyQuant architect

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.