luyikaibr

Custom EMA Prism

luyikaibr 已更新   
This script implements the Binary Logic Trading (BLT) algorithm to calculate a score from 0 to 7. This score is calculated assigning a power of 2 weight to the positive sign of 3 Phi^3 distant EMAs' slopes. The largest EMA slope positive sign receives weight 4, the middle length EMA slope positive sign receives weight 2 and the shortest EMA slope positive sign receives weight 1. The positive sign of an EMA is defined as 1 if the slope of the EMA is positive and 0, otherwise. Therefore, for EMAs 305, 72 and 17, if slope(EMA305) > 0, slope(EMA72) < 0 and slope(EMA17) > 0, then score will be 4*1 + 2*0 + 1*1 = 5. Up to my knowledge, this score was first proposed by Bo Williams and named by him as Prisma.

Due too sampling issues, this script ONLY WORKS with graphic time of 1d. I would like to thanks to MrBitmanBob for showing me how to get quotations from a graphic time distinct from the current one.

This script also gets sampling data from graphic times 2h and 30m to calculate their score. As, even for smaller graphic times, price data is sampled at the current time frequency, the EMA lengths for those smaller graphic times needed to be proportionally decreased, meaning that when calculating the score for 1d with lengths 305, 72 and 17, the score for 2h must be calculated with lengths 72, 17 and 4, and the score for 30m must be calculated with lengths 17, 4 an 1. I understand that some precision may be lost but it is the best that is possible.

There is an optional setting for Crypto Currencies that instead of calculating the score for 1d, 2h and 30m, it calculates the score for 1d, 4h and 60m. This is due to the fact that Crypto Currencies are traded 24x7. Despite of this setting, the labels at the Style tab of the settings window remains 2h and 30m, because they must be constants.

This script with the corresponding EMAs chart and the EMAs Angle chart provides a broader view of the trading scenario.


版本注释:
This update normalizes the price before calculating the angle in order to minimize rounding loss of precision. It also adds an option to use current data src instead of using security() to retrieve smaller times. This option is due to my lack of confidence that this security() function returns useful data.
版本注释:
Due to the lack o accuracy on smaller graphic times, this update simplifies the indicator to show just the prism score for the current graphic time.
版本注释:
his update is just to change sample chart.
版本注释:
*This update...
版本注释:
This update is just to make it clear that this indicator now works fine with every graphic time, not only 1d as before. For sharper candle movements delta should be set to 2, otherwise 4 works fine.
版本注释:
This update brings back other graphic times score calculation with some options offered. I finally managed to understand how to properly operate on distinct graphic times with security() function. I believe it works on any graphic time but I recommend it to be used with 1d.
版本注释:
This update just changes the order the scores are plot in order to make their value order match the order displayed by the chosen graphic times.
版本注释:
This update is just to fix the EMA calculation in the absence of enough candles. Instead of using TV standard zero price, I use the source (close) price.
版本注释:
This update adds the concept of Prism of Prism, calculating a new line that shows the score of the 3 scores. It also adds 2 new sets of graphic time options and it changes the default length of the top MA to 610. It the Buy and Sell indication conditions.
版本注释:
This update adds a new and more meaningful angle calculation method.
版本注释:
This update just optimizes some functions to use binary search and decrease average execution time from n/2 to log2(n). It also adds some options to available graphic times.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?