![]() |
|
| Forex Broker Rebates | Top Free Expert Advisors - 01/29 | Top Commercial Expert Advisors - 01/29 |
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
||||
![]() 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% |
|
|||
|
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; } |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Waddah Attar Trend EA | funyoo | Expert advisors backtesting | 33 | 09-16-2009 02:34 AM |
| Waddah Attar Win Expert | funyoo | Expert advisors backtesting | 10 | 02-25-2009 06:35 PM |
| Waddah Attar Win | funyoo | Expert advisors demo statements | 5 | 11-13-2008 10:26 AM |
| Waddah Attar Trend EA | funyoo | Expert advisors demo statements | 0 | 11-13-2008 09:57 AM |