Here you go. You can change the Length input to “34” in the settings.
//@version=3
study(title=“Percent difference between price and MA”)
Length = input(14, minval=1)
xSMA = sma(close, Length)
nRes = abs(close - xSMA) * 100 / close
timeframe = period
finalRes = if xSMA > close
-1*nRes
else
nRes
//USDJPY, EURJPY, GBPJPY, CHFJPY, AUDJPY, NZDJPY, CADJPY
//Plot for USDJPY
usdjpy = security(“USDJPY”, timeframe, finalRes)
plot(usdjpy, color=blue, title=“USDJPY”)
//Plot for EURJPY
eurjpy = security(“EURJPY”, timeframe, finalRes)
plot(eurjpy, color=orange, title=“EURJPY”)
//Plot for GBPJPY
gbpjpy = security(“GBPJPY”, timeframe, finalRes)
plot(gbpjpy, color=green, title=“GBPJPY”)
//Plot for CHFJPY
chfjpy = security(“CHFJPY”, timeframe, finalRes)
plot(chfjpy, color=black, title=“CHFJPY”)
//Plot for AUDJPY
audjpy = security(“AUDJPY”, timeframe, finalRes)
plot(audjpy, color=red, title=“AUDJPY”)
//Plot for NZDJPY
nzdjpy = security(“NZDJPY”, timeframe, finalRes)
plot(nzdjpy, color=maroon, title=“NZDJPY”)
//Plot for CADJPY
cadjpy = security(“CADJPY”, timeframe, finalRes)
plot(cadjpy, color=purple, title=“CADJPY”)
//Plot for JPYJPY
plot(0, color=yellow, title=“JPYJPY”)