Results 1 to 2 of 2
 3 Attachment(s)    

Thread: Waddah Attar Def RSI EA

  1. #1
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default Waddah Attar Def RSI EA




    An expert advisor based on the Waddah_Attar_Def_RSI indicator.

    EU H1. RSIPeriod1=112; RSIPeriod2=224.

    Total net profit : 9.53%
    RDD : 15.46%
    Attached Images Attached Images Waddah Attar Def RSI EA-strategytester-waddah_attar_def_rsi-ea-eu-h1-gif 
    Attached Files Attached Files

  2. #2
    Junior Member
    Join Date
    Jul 2009
    Posts
    3

    Default Seemingly useless code in EA

    As a 20 year C coder, I always look to optimize code I get my hands on, makes it run faster and helps me learn what the program is up to. I was cleaning up the style of the EA and came upon the following snippit which initially made no sense to me. But on further examination appears to be some sloppy editing which has introduced a logic error.

    // expert init positions
    int cnt=0,OP=0,OS=0,OB=0,CS=0,CB=0;
    OP=0;
    // Locate the number of orders for this EA instance.
    for(cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if((OrderType()==OP_SELL||OrderType()==OP_BUY)&&Or derSymbol()==Symbol()&&((OrderMagicNumber()==Magic )||Magic==0))
    OP=OP+1;
    }
    if(OP>=1)
    {
    OS=0;
    OB=0;
    }
    OB=0;
    OS=0;
    CB=0;
    CS=0;

    I spread it out for ease of reading. What I see here is that if OP is positive, then OS and OB are set to zero. However, regardless of the values of OP, all 4 values OB,OS,CB,and CS are set to zero. So, if this is the case, why is the if statement there at all? What I think happened is that the setting of the 4 values is part of an initializer that is begun with the setting of OP=0 at the top of this code snippet. Somehow the code segment to calculate the value of OP got shoved in between, which would be incorrect.

    One also must wonder why these 5 statements are even there since the values are all explicitly set to zero in the variable definition statement. I am thinking that the code should look like the following.

    // expert init positions
    int cnt=0,OP=0,OS=0,OB=0,CS=0,CB=0;

    // Locate the number of orders for this EA instance.
    for(cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if((OrderType()==OP_SELL||OrderType()==OP_BUY)&&Or derSymbol()==Symbol()&&((OrderMagicNumber()==Magic )||Magic==0))
    OP=OP+1;
    }
    if(OP>=1)
    {
    OS=0;
    OB=0;
    }

Similar Threads

  1. Waddah Attar Win Expert
    By funyoo in forum Expert advisors backtesting
    Replies: 14
    Last Post: 03-10-2010, 12:54
  2. Waddah Attar Win
    By funyoo in forum Expert advisors live statements
    Replies: 6
    Last Post: 03-08-2010, 19:32
  3. Waddah Attar Scalping EA
    By claypot in forum Ideas for expert advisors
    Replies: 1
    Last Post: 12-03-2009, 17:57
  4. Waddah Attar Trend EA
    By funyoo in forum Expert advisors backtesting
    Replies: 33
    Last Post: 09-16-2009, 02:34
  5. Waddah Attar Trend EA
    By funyoo in forum Expert advisors live statements
    Replies: 0
    Last Post: 11-13-2008, 09:57

Tags for this Thread

advisor, expert, expert advisor, indicator, learn, mql, mql4, profit, rsi, spread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •