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!
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.
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.
...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