| / | Forum |
|
flaw
2007.10.04 04:35
Hello,
ive bin really, really trying to code an EA function that would do the following. It would find the value of the MA in the last two closed bars and see if their is a difference of 'MinAng' in are case 5, between the two and in what direction. ex. shift 1 - 2.0325 (one bar back) shift 2 - 2.0321 ( two bar back) 25 -21 ____ 4 4 is not equal or greater than 5 so return 0 I've tryed the following but it only works some of the time and only when the difference is greater than 5... not equal. extern int angle = 5; int Mangle = MAngle(angle); int MAngle(double MinAng) { double thspos = NormalizeDouble(iMA (NULL, 0, period, 0, MODE_SMA, PRICE_CLOSE, 1), Digits); double lstpos = NormalizeDouble(iMA (NULL, 0, period, 0, MODE_SMA, PRICE_CLOSE, 2), Digits); if (thspos >= (lstpos + MinAng*Point)) {return(1);} //up if (thspos <= (lstpos - MinAng*Point)) {return(2);} //down return(0); }the rest of the code that involves this function is with the buy/sell. but that only uses the what it returns (1, 2, 0). |
|
All about Automated Trading Championship: Interviews with the Participants'07 The published interviews of Championship 2007 bear the stamp of the results obtained during the preceding contest. The first Championship evoked a wide response on the internet and in printings. The leading developer of the MetaQuotes Software Corp. tells about changes made to the forthcoming Automated Trading Championship 2007. We put our questions to the developer of a well-known indicating complex ZUP, Eugeni Neumoin (nen) and spoke to an equity trader, Alexander Pozdnishev (AlexSilver). |
33780 |
Rosh
2007.10.04 16:58
|
|
flaw
2007.10.04 22:00
I looked into those threads and it seems that the solutions were to use the "NormalizeDouble" subroutine. would it be better just to define my MAs as strings? i already used that subroutine and it still didn't work. |
|
phy
2007.10.05 01:02
You didn't use it here: if (thspos >= (lstpos + MinAng*Point)) {return(1);} //up |
|
flaw
2007.10.05 18:00
yup that did the trick phy.
it seems it didnt carry over from when i declared them. |