repo32

Moving Average Colored EMA/SMA

This script will give you the ability to put an EMA and/or SMA on the chart that changes color based upon the direction. Default at startup is EMA visible and SMA hidden. When the MA is moving up, it is green. When the MA is moving down, it is red. You can change the color to whatever you like.
نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟
//Created by Robert Nance on 072315
study(title="Moving Average Colored EMA/SMA", shorttitle="Colored EMA /SMA", overlay=true)
emaplot = input (true, title="Show EMA on chart")
len = input(8, minval=1, title="ema Length")
src = close
out = ema(src, len)
up = out > out[1]
down = out < out[1]
mycolor = up ? green : down ? red : blue
plot(out and emaplot ? out :na, title="EMA", color=mycolor, linewidth=3)


smaplot = input (false, title="Show SMA on chart")
len2 = input(8, minval=1, title="sma Length")
src2 = close
out2 = sma(src2, len2)
up2 = out2 > out2[1]
down2 = out2 < out2[1]
mycolor2 = up2 ? green : down2 ? red : blue
plot(out2 and smaplot ? out2 :na , title="SMA", color=mycolor2, linewidth=1)