peacefulLizard50262

Daily Reset CWEMA/CWTEMA

This Pine Script code defines an indicator called "Daily Reset CWEMA" that plots a custom weighted moving average on a chart. The indicator takes three inputs: a source series (usually the close price of a security), a length parameter that specifies the number of periods over which the moving average is calculated, and a style parameter that specifies the type of moving average to use (either a custom weighted exponential moving average (CWEMA) or a custom weighted triple exponential moving average (CWTEMA)).

The code first checks the current time frame and adjusts the length parameter accordingly. If the time frame is daily, weekly, or monthly, the length parameter is used as-is. Otherwise, the length is set to the number of bars since the last day change, unless this value is less than the length parameter, in which case the length is set to the number of bars since the last day change.

The ema(), tema(), wma(), cwema(), and cwtema() functions are then defined. The ema() function calculates the exponential moving average of the source data using the number of bars since the last day change as the length. The tema() function calculates the triple exponential moving average of the source data using the number of bars since the last day change as the length. The wma() function calculates the weighted moving average of the source data using the given weights and the number of bars since the last day change as the length. The cwema() and cwtema() functions are similar to the wma() function, but use the ema() and tema() functions to calculate the moving average values instead of the source data directly.

Finally, the ma() function is defined, which takes the source data, length, and style as inputs and calls the appropriate moving average function based on the style parameter. The result of this function is then plotted on the chart.

Suggested by: @ASIFKERIM

نص برمجي مفتوح المصدر

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

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

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

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟