I want to measure the difference once bar at the time of an EMA to determine if it is increasing or decreasing.
My problem is I can't seem to figure out how to store the newer EMA value until it becomes the older value, so I can compare it to the later EMA value.
I know it must be simple. In the good old days I would have done it in FORTRAN and just written a sub-routine (yes, that is how long since I've done any programming) - be greatful if someone could help
Jim
Hi Jim,
If I understand your question correctly, you don't really need to "store" the older values for the MA's...
You just need to get the CURRENT and PAST values during each cycle and compare them directly each time.
Use the "shift" bar to get the past "older" MA values...
double DiffMAValues = 0;
MAValueCurrent = iMA (NULL,TimeFrame,MAPeriod,0,MAMethod,MAPrice,0);MAValuePrevious = iMA (NULL,TimeFrame,MAPeriod,0,MAMethod,MAPrice,1);
DiffMAValues = MAValueCurrent - MAValuePrevious;
Hope this helps you,
Robert
Hi Jim,
If I understand your question correctly, you don't really need to "store" the older values for the MA's...
You just need to get the CURRENT and PAST values during each cycle and compare them directly each time.
Use the "shift" bar to get the past "older" MA values...
double DiffMAValues = 0;
MAValueCurrent = iMA (NULL,TimeFrame,MAPeriod,0,MAMethod,MAPrice,0);MAValuePrevious = iMA (NULL,TimeFrame,MAPeriod,0,MAMethod,MAPrice,1);
DiffMAValues = MAValueCurrent - MAValuePrevious;
Hope this helps you,
Robert
Sorry it took so long to get back to you. Just wanted to thank you for what must now seem a really silly question. I got myself the Andrew Young book and life is a lot simpler.
thanks

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to measure the difference once bar at the time of an EMA to determine if it is increasing or decreasing.
My problem is I can't seem to figure out how to store the newer EMA value until it becomes the older value, so I can compare it to the later EMA value.
I know it must be simple. In the good old days I would have done it in FORTRAN and just written a sub-routine (yes, that is how long since I've done any programming) - be greatful if someone could help
Jim