Board logo

标题: [TS源码] Adjustable weighting percent blended moving average指标公式 [打印本页]

作者: 龙听    时间: 2020-11-28 07:42     标题: Adjustable weighting percent blended moving average指标公式

本帖隐藏的内容需要回复才可以浏览

作者: 龙听    时间: 2020-11-28 07:44

You can read the above code first before creating this indicator and see if you can see what it is doing.

There are two moving averages used with slow length of 50 and a fast length of 20, the input called factor is adjustable to assign a weighting to each one.

If factor is set to 0.5 it will add 50% of the slow average to 50% of the fast average and create a blended average of the two periods.

To see maximum values of the slow average set factor to 1, to see the plot constructed entirely of the faster average you can set factor to 0.

You can experiment with values like 0.1 and 0.9 to see the affects of adjustments to the weighting.

Code tips

If you use the name value1 or value2 or value 99 as variables, then you do not need to declare the names of these at the top part.

Value2= 1-factor is a very neat way to get 2 variables to automatically assign 1% of one part and 99% of the other part so when added they will always = 100%

Limit the user error by restricting inputs by making the variables read them. ( The code for value1 does this after reading the factor input )

Code tricks to try

If you look at the slow and fast variables you will see they both use averages (average is this code means simple average).

You can try making the slow one into a weighted average or an exponential average and mixing these up to make your own blended average combination.

在创建此指标之前,您可以先阅读上面的代码,看看是否可以看到它在做什么。

有两种移动平均值,慢速长度为50,快速长度为20,称为因子的输入是可调的,可以为每个加权平均。

如果因子设置为0.5,它将把慢速平均值的50%加到快速平均值的50%,并创建两个周期的混合平均值。

要查看慢平均设置因子的最大值为1,要查看完全由快平均构成的图,可以将因子设置为0。

您可以尝试使用0.1和0.9之类的值来查看权重调整的影响。

代码提示

如果使用名称value1或value2或value 99作为变量,则无需在顶部声明这些名称。

值2 = 1因子是一种非常巧妙的方法,可让2个变量自动分配一部分的1%和另一部分的99%,因此添加它们时,它们总是= 100%

通过使变量读取输入来限制输入,从而限制用户错误。 (value1的代码在读取因子输入后执行此操作)

尝试的代码技巧

如果查看慢速和快速变量,您会发现它们都使用平均值(平均值是该代码表示​​简单的平均值)。

您可以尝试将慢速平均值变成加权平均值或指数平均值,然后将它们混合起来以形成自己的混合平均值组合。
作者: 阿土伯    时间: 2020-12-3 16:07

学习




欢迎光临 龙听期货论坛 (http://qhlt.club/) Powered by Discuz! 7.2