Change code from SMA to EMA?

Baller2356

New member
How do you change this code to work for an ema instead of sma?

Code:
input SMA_Length = 200;
def ma = simpleMovingAvg("length"= SMA_Length);
def triggerLow = open > ma and low <= ma;
def triggerHigh = open < ma and high >= ma;
def MasterTrigger = TriggerHigh and TriggerLow;
plot SmaTouch = triggerHigh or triggerLow;
 

MerryDay

Well-known member
VIP
Code:
def ma = ExpAverage(close, 200);
def triggerLow = open > ma and low <= ma;
def triggerHigh = open < ma and high >= ma;
def MasterTrigger = TriggerHigh and TriggerLow;
plot EmaTouch = triggerHigh or triggerLow;
 

Similar threads

Top