Download MetaTrader 5
To add comments, please log in or register
No PC at hand? Communicate with friends using your mobile phone!
AUGUSTUS
20
AUGUSTUS 2014.04.06 15:32 

Hi all,

I need to add a single moving Average to an EA I am using, I will use the moving average to determine if the trend is up or down.

I just need to very simply compare the current candle MA to the last candle MA to give me my 'UP' or 'Down' trend indication (is MA greater or less than last candle MA?)

I'm confident in feeding the UP/Down into my Buy/Sell triggers, but I'm not sure how to add the MA or perform the above calc?

Any help would be much appreciated!

Thanks

Aug

whroeder1
13644
whroeder1 2014.04.06 15:45  
augustus: I need to add a single moving Average to an EA ... but I'm not sure how to add the MA or perform the above calc?
Read the book, read the docs especially iMA - MQL4 Documentation
AUGUSTUS
20
AUGUSTUS 2014.04.07 00:05  
WHRoeder:
Read the book, read the docs especially iMA - MQL4 Documentation


Thanks, I'll have a look at iMA and see how I get on.

Aug.

AUGUSTUS
20
AUGUSTUS 2014.04.07 08:02  
augustus:


Thanks, I'll have a look at iMA and see how I get on.

Aug.


I've added a MA ok using iMA, but I'm not sure how to do the below - all the examples I can find are for MA crossovers, where as I want to compare the MA to itself to determine the slope.

I want to effectively be able to do this:

MA[1] > MA[2]


Thanks.

Tjipke de Vries
6283
Tjipke de Vries 2014.04.07 08:15  
augustus:


I've added a MA ok using iMA, but I'm not sure how to do the below - all the examples I can find are for MA crossovers, where as I want to compare the MA to itself to determine the slope.

I want to effectively be able to do this:

MA[1] > MA[2]


Thanks.

a moving average of a moving average
iMAOnArray
AUGUSTUS
20
AUGUSTUS 2014.04.07 08:24  
deVries:
a moving average of a moving average
iMAOnArray

Ah, thanks :)
whroeder1
13644
whroeder1 2014.04.07 12:21  
augustus: MA to itself to determine the slope. MA[1] > MA[2]
iMAOnArray is irrelevant - the OP wants the slope. What is the last parameter in iMA? What does your 1 and 2 mean?
AUGUSTUS
20
AUGUSTUS 2014.04.07 16:20  
WHRoeder:
iMAOnArray is irrelevant. What is the last parameter in iMA? What does your 1 and 2 mean?


If I have a 100 SMA moving average, I would like to compare the SMA value 1 candle ago against 2 candles ago, to determine if the slope of the SMA is currently up or down.

Thanks

whroeder1
13644
whroeder1 2014.04.07 16:23  
Answer my other question.
AUGUSTUS
20
AUGUSTUS 2014.04.07 16:44  
WHRoeder:
Answer my other question.


The Shift? So I could create two iMA's with a Shift of 0 and 1 respectively, and this would effectively give me the last and second to last values from the moving average? If so, sounds good.

Just an aside, is there any best practice to ensure when using MA's in an EA that you avoid 'looking into the future' when using the strategy tester? If I use a shift of 0 will it always be entirely safe?

/
To add comments, please log in or register