| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| conditions on different time frames https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2106 |
Page 1 of 1 |
| Author: | Dewey McG [ Thu May 09, 2013 6:12 pm ] |
| Post subject: | conditions on different time frames |
Sorry for such a newbie question. I thought this should be simple but it isn't working. I wanted to make a simple EA to test an idea I saw (before modifying it further) that would check to see if price is above both EMA 20 and EMA 50 on the Daily time frame, then place an order on the H1 time frame to go long when Williams%R is less then -80. ((The opposite for going short)I did this: // Go Long 1 if (((sqGetMarketPosition() == 0) && ((iOpen(NULL, PERIOD_D1, 1) > iMA(NULL, 0 , 50, 0, MODE_EMA, 0, 1)) && ((iOpen(NULL, PERIOD_D1, 1) > iMA(NULL, 0 , 20, 0, MODE_EMA, 0, 1)) && (iWPR(NULL, 0 , 14 , 1) < (-80)))))) then placed the EA on the H1 chart. However, it ignores the first condition, taking orders even when the price on the Daily is under EMA 20. What am I doing wrong? I probably should have used Daily close from the previous bar but even when price was well under EMA 20 on both open and close it was placing trades. |
|
| Author: | Dewey McG [ Thu May 09, 2013 8:28 pm ] |
| Post subject: | Re: conditions on different time frames |
I think I fixed it: // Go Long 1 if (((sqGetMarketPosition() == 0) && ((iClose(NULL, PERIOD_D1, 1) > iMA(NULL, 1440 , 50, 0, MODE_EMA, 0, 1)) && ((iOpen(NULL, PERIOD_D1, 1) > iMA(NULL, 1440 , 20, 0, MODE_EMA, 0, 1)) && (iWPR(NULL, 60 , 14 , 1) < (-80)))))) |
|
| Author: | dietcoke [ Thu May 09, 2013 8:40 pm ] |
| Post subject: | Re: conditions on different time frames |
You cannot see the wood for the trees here. You should use variables when you can as it's much easier to see whats going on. Second, I've removed all the excess brackets as well and finally added a print statement to inspect the values you are getting. It may still be wrong but you should be able to see better. Code: Select all |
|
| Author: | Dewey McG [ Thu May 09, 2013 11:05 pm ] |
| Post subject: | Re: conditions on different time frames |
Thanks--yours is much cleaner. |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|