Crossover of EMA with shifted EMA
Author: MarioJunior
Creation Date: 5/21/2020 5:25 PM
profile picture

MarioJunior

#1
Hi, I'm new here using WL and, please, I need some help with that strategy code below.

It even plots the moving averages on the chart, but doesn't perform the operations.

Thanks in advance for attention!

The intention is simple: I have two 10 periods exponential moving averages, one of which is shifted by 1 period. When the non-shifted average cross over the shifted, a buy at the candle close must occur where the crossing occurs, with a stop loss below the low of this candle, being the trade exit (take profit), when the non-shifted average passes below the shifted.

CODE:
Please log in to see this code.
profile picture

Eugene

#2
Hi Mario,

The code does perform the operations and doesn't require changes. However, the entry will not trigger Alerts as it's an AtClose order. You should convert it into an AtMarket order as in code below for Alerts to work.

Check out the Wiki FAQ > Alerts are not triggered.

CODE:
Please log in to see this code.
profile picture

MarioJunior

#3
Eugene, eternal thanks for the quick and accurate answer!
profile picture

Eugene

#4
Mario,

My pleasure to help.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).