Ema touch price / ema pullback MT5 - page 2

 

@Jugurtha82, here's another version with selectable cross or proximity.

@Conor Mcnamara, Momentum is omitted as it is not in the OP's requirements.

 
Ryan L Johnson #:

@Conor Mcnamara, Momentum is omitted as it is not in the OP's requirements.

the thing is though that moving averages by themselves can never confirm a direction of price movement (or do a bad job of it), so without momentum there will be a lot of repainted arrows

 
Conor Mcnamara #:

the thing is though that moving averages by themselves can never confirm a direction of price movement (or do a bad job of it), so without momentum there will be a lot of repainted arrows

Oh, I mistook your request as a mere suggestion. Will do...
 
Conor Mcnamara #:

my original indicator was more so about crossing the price (with a point filter for confirmation)

If the criteria is not about crossing the price:

1. Find when the price is very close to the moving average (not crossing)

2. Examine the momentum to confirm a divergence from the moving average

I hate to say go to freelance, but hopefully you can understand code that was given and modify things (iMA, and iMomentum)

the momentum value provided by iMomentum is always normalized around 100, that's why you use it that way


- the momentum divergence will never be true at the same time that the price is close to/touching the moving average, so you have to create a global variable for state tracking and set a flag to true when the price is close to the MA...and then when that is true, you wait for the momentum divergence to be true. 

Here you go, bro. I made the MA state tracking global an int that resets to 0 (neutral) upon Momentum leaving trading conditions.

Loads without issue. Tested some inputs without issue. But basically, untested.

 
Ryan L Johnson #:

Here you go, bro. I made the MA state tracking global an int that resets to 0 (neutral) upon Momentum leaving trading conditions.

Loads without issue. Tested some inputs without issue. But basically, untested.

 
Well it's nice to code it for him, but this wasn't so simple as the OP originally assumed. Usually these threads are shunned as it was essentially a freelance request that wasn't in the freelance section. 
 

Found a misplaced curly bracket the code.

Fixed in v2 (attached).

 
Conor Mcnamara #:
 
Well it's nice to code it for him, but this wasn't so simple as the OP originally assumed. Usually these threads are shunned as it was essentially a freelance request that wasn't in the freelance section. 

I figure that the CodeBase is the quintessential place for free code. You seem to have disclosed a dual indicator strategy here, so nice back at you.

With inputs Cross on, Mom on, and your original numerical settings used, the indicator appears to be highly selective at catching price runs:

EURUSDM1