Trading System Forex
Forex Broker Rebates | Top Free Expert Advisors - 01/29 | Top Commercial Expert Advisors - 01/29

Go Back   Trading System Forex > Automated trading systems > Expert advisors backtesting
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-17-2008, 12:10 PM
funyoo's Avatar
Administrator
 
Join Date: Sep 2008
Posts: 4,740
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
File Type: gif StrategyTester Waddah_Attar_Def_RSI EA EU H1.gif (6.1 KB, 683 views)
Attached Files
File Type: htm StrategyTester Waddah_Attar_Def_RSI EA EU H1.htm (160.3 KB, 126 views)
File Type: mq4 Waddah_Attar_Def_RSI EA.mq4 (6.2 KB, 176 views)
File Type: mq4 Waddah_Attar_Def_RSI.mq4 (2.4 KB, 150 views)
__________________
Trading forex risk disclaimer. Exclusive EAs in the Elite section.
Reply With Quote
  #2 (permalink)  
Old 07-11-2009, 11:37 PM
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;
}
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

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



All times are GMT. The time now is 11:44 AM.



Powered by vBulletin®
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.