Hi,
How do I code the following condition?
Long
20 Exponential Moving average crosses over the 50 Exponential moving average in the last 20 bars
Assuming you want a Screener, try this?
Filter = SUMMATION[20] (ExponentialAverage[20](close) crosses over ExponentialAverage[50](close))
Screener (Filter)
Thanks I’ll give it a try.
I just noticed you said ‘Long’ so you probably need this?
If SUMMATION[20] (ExponentialAverage[20](close) crosses over ExponentialAverage[50](close)) Then
Buy 1 Contract at Market
Endif
… and how would I also test if price crossed over the 50EMA in the previous X bars?
I tried the below but didn’t work:
SUMMATION[X](close) crosses over ExponentialAverage[50](close)) Then
GraHal were almost correct, the summation should be tested if it is at least equal to 1:
If SUMMATION[20] (ExponentialAverage[20](close) crosses over ExponentialAverage[50](close))>=1 Then
Buy 1 Contract at Market
Endif
Here, the moving average cross over may have occured more than once, you can also modified the condition with “=1” instead of “>=1”.