Need Help with my EA

 

Hey all. Could really use someone's help. 

I'm having trouble with a couple issues on my EA. When I perform a backtest from Septemeber 1, 2012 to today, the EA only opens long positions. It will not create sell orders, and I have no idea why. My backtest settings are set to create long and short positions so I am at a loss?

Also, I want to add time constraints on when the EA is allowed to trade. I want it to trade between 12:00am (Midnight) to 12:00pm (Noon) New York time.  I am using FXOpen as my broker server and they are using GMT +3 as their time. Not sure if that's relevant or not but ya.

I have attached my code hoping someone can play with it and help me figure out how to fix it. Thanks a million!

Files:
 
  1. ForexEAdvisor.com contains lots of problems. see https://www.mql5.com/en/forum/139865
  2. What are Function return values ? How do I use them ? - MQL4 forum
  3. Do you have history for the H4 chart (your iMAs) and M5 (your TSL) for the period of you backtest?
 

Thank you for the responses. I will review the posts you sent.

Yes I have the correct history data loaded. I erased the history files altogether and then shifted back using M1, M5 and H4 timeframes to re-download the most current history for the past 2 months. Perhaps someone could run a quick 2 month backtest for the EURUSD and see if it works for them or not? Regardless of the results, I just want to see that it sells, and where I could make improvements, seeing as how I can't seem to do it for myself :S Thanks for the support! I will try to add the time constraints to my code and report back. 

 

I was able to get the time working. I used:

if (Hour() > StartTime || Hour() < Endtime) 

 

I was making the mistake of using && instead of ||. Couldn't believe I didn't notice.

But anyway I'm still having trouble getting it to open a sell order. I would really like to know why. Any help would be greatly appreciated. Thanks.

 
huh?  IF start= 10:00 and end=1800 and now= 5:00 then  if( 5>10 || 5<18) is true. Useing || means the if will always be true no matter what the current hour is.
 

Retesting the above, you are right WHRoeder. Derp.

I am out of ideas. When I used:

if (Hour() > 19 && Hour() < 10) ... BUY/SELL 

...it would not open any orders. And using || it opens orders at any time. Not sure if I will even worry about the time constraints anyway but I would just like to know how to get it to work for future reference. Any ideas? 

 

Also, I re-made my EA using http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ and it now opens buys and sells. Thank you WHRoeder for letting me know forexEadvisor was garbage. Now I should be able to tweak it. Thanks again. 

 
mattmoneywilson:


Also, I re-made my EA using http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ and it now opens buys and sells. Thank you WHRoeder for letting me know forexEadvisor was garbage. Now I should be able to tweak it. Thanks again. 

Out of the frying pan and into the fire . . .
 
mattmoneywilson:

Retesting the above, you are right WHRoeder. Derp.

if (Hour() > 19 && Hour() < 10) ... BUY/SELL 

...it would not open any orders.

Of course not. if the hour is above 19 then it will never be below 10. the IF will never be true.

try if (10 < Hour() && Hour() < 19) to trade between 11:00 and 18:59