如何操纵价格序列(指标)围绕中心值振荡?

发布于 2024-10-27 01:21:18 字数 1156 浏览 0 评论 0原文

我不是专业程序员,但我正在尝试改变一些技术指标在名为 TradeStation 的金融图表包中显示的方式(与特定图表供应商无关)。

问题是:大多数指标都是围绕零点绘制的,有时它们在接近该点的地方振荡,有时则远离该点。我想改变指标的绘制方式,以便它们在零附近振荡更多。但这是棘手的部分,我不想太多地扭曲它们的形状;一些变化是好的,也是不可避免的,但我仍然希望这些指标能够被识别为原来的样子。

过去我尝试过很多方法,其中一种方法是使用对数型刻度,但这并不成功,因为它使得任何处于非常高值的振荡几乎无关紧要——这不是目标。目标是尝试保持指标的任何一个振荡几乎相同,但改变其位置,使其更接近零(中心)。或者换句话说;目标是使指标执行类似形状的振荡,但这些振荡的中心应更接近零(指标刻度的中心)。

有谁知道或能想到一种可以做到这一点的方法?是否有任何算法可以帮助任何价格系列在中心点周围更多地振荡,而不会对原始数据造成太多扭曲?

对此的任何帮助将不胜感激,谢谢。

==更新== 在此处输入图像描述 粉色线是原始振荡器,黑色线是我画的。它粗略地代表了我的目标。圆圈区域显示了绘制的线与零相交的位置,因此其零值大致位于振荡的中心......但与原始振荡相比,振荡的整体形状仍然可以识别,而且高点的差异也较小和每次振荡的低点;即它们的值更相似。我曾尝试向各种指标添加几种不同的去趋势函数,但我发现这会使形状扭曲太多。

更新 2

我尝试过将 y 轴线性减少 50% 和 80%,不幸的是,这似乎与比例因子的作用相同?这是正确的吗?它似乎并没有改变不同振荡之间的关系。如果您看到我的示例图,则绘制的黑线具有更稳定的高低振荡,即它们的值/大小更相似,这是关键目标。

接下来,我将尝试在图中添加高通滤波器,看看给出的结果以及它是否更接近我的目标。

像往常一样,请随时发表任何评论,我们将不胜感激。

Chris

更新 3

我还为指标实现了高通滤波器。这也没有达到目的。这似乎也起到了比例因子的作用。我本质上追求的是让大的振荡变小,让小振荡变大。将所使用的任何指标纳入更同步的范围,并同时保持相关指标的基本属性。更好的描述方式可能是我正在寻找阻尼公式?

有人有任何其他想法,或者我应该尝试的事情吗?

I’m no expert programmer, but I’m attempting to change the way in which some technical indicators are displayed in a financial charting package called TradeStation (not that the specific charting supplier is relevant).

Here is the problem: Most indicators are plotted around a Zero point, sometimes they oscillate close to this point and sometimes far away. I would like to change the way in which the indicators are plotted so that they oscillate around Zero much more. But here is the tricky part, I don’t wish to distort their shape too much; some change is fine and inevitable, but I still would like the indicators to be recognisable for what they originally were.

In the past I have tried many ways, one way was using a logarithmic type scale, but this was not successful as it made any oscillation that was at a very high value almost inconsequential- which is not the goal. The goal is to try to keep any one oscillation of the indicator almost the same, but change the placement of it so that its closer to Zero (centre). Or put another way; the goal is to make the indicators perform similar shaped oscillations, but the centre of these oscillations should be closer to Zero (the centre of the indicators scale).

Does anyone know of, or can think of a way that this can be done? Are there any algorithms that might help keep any price series oscillating more around a centre point without too much distortion to the original?

Any help on this would be greatly appreciated, thank you.

==UPDATE==
enter image description here
The pink line is the original oscillator, the black line I have drawn in. It crudely represents what my goal would be for this. The circled areas show where the drawn in line crosses Zero so that its Zero value is roughly in the center of the oscillation... But the overall shape of the oscillation remains recognizable compared to the original one, also there is less discrepancy in the highs and lows of each oscillation; i.e. they are more similar in value . I have tried adding several different Detrend functions to various indicators but I have found that this distorts the shape for too much.

UPDATE 2

I have tried dividing reducing linearly the y axis by 50% and 80%, Unfortunately this seems to just act in the same was as a scale factor would? Is this correct? It does not seem to change the relationship between different oscillations. If you see my example plot, the drawn in black line has more stable high and low oscillations i.e they are more similar in value/size and this is the key goal.

Next, I am going to try to add a high pass filter to the plot to see what result that gives and if it is closer in any way to my goal.

As usual, feel free to post any comments as they are gratefully received.

Chris

UPDATE 3

I have also implemented a high pass filter to an indicator. This did not do the trick either. This also seems to act as a scale factor. What I am after essentially, is to make large oscillations smaller, and small oscillations larger. Bringing any indicator used into a more synchronised range- and do this while maintaining the basic properties of the indicator in question. A better way to describe it may be that I'm after a damping formula?

Does anyone have any other ideas, or things I should be trying?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

非要怀念 2024-11-03 01:21:18

如果您想做一些定制的事情,您可以例如过滤傅立叶变换的低频分量。

假设我们有以下信号:

在此处输入图像描述

然后我们计算 FFT,并仅保留较高频率的分量。假设我们忽略了前 1.5% 的组件。
原始信号和振荡信号的结果图是:

在此处输入图像描述

HTH!

编辑 2

这是您可以从如上所述的高通滤波器中得到的结果,添加指数阻尼,而不是仅仅处理低频分量。

Mathematica 中的程序(以防万一):

centerOsc[x_] := 
  Module[{list, n, fp, coef, s}, 
   list = (Transpose@FinancialData[#, "Jan. 1, 2005"])[[2]] &@x;
   n = Length@list;
   fp = Transpose[{N[Range[n]]/n, list}];
   coef = FourierDST[list, 1]/Sqrt[n/2];
   coef = Table[N[coef[[i]] (1 - E^(-i/6))], {i, 1, Length@coef}];
   s = IntegerPart[Length@coef/100]; s = 1;
   {fp, {#, 
       Sum[coef[[r]]*Sin[Pi r #], {r, s, n - 1}]} & /@ (N[Range[n]]/
       n)}];
l = {"GE", "GOOG", "IBM", "MSFT"} ;(*Real prices from*)
GraphicsGrid@
 Partition[ListLinePlot[centerOsc[#],
     Axes -> False, Frame -> True, PlotLabel -> #,
     PlotRange -> {{0.1, .9}, Full}, 
     Epilog -> Line[{{0, 0}, {1, 0}}]] & /@ l, 2]

在此处输入图像描述

编辑 2

基于您的上一次更新一下,看来你想要的东西可以更容易实现了。只需看看将 y 轴线性减少 50% 和 80% 所得到的结果(使用从图中提取的您的数据):

在此处输入图像描述

并与您的绘图进行比较:

在此处输入图像描述

If you want to do something tailor-made, you could for example filter the low frequency components of the Fourier transform.

Suppose we have the following signal:

enter image description here

Then we calculate the FFT, and keep only the higher frequency components. Let's say we disregard the first 1.5% of the components.
The resulting Plot of the original signal and the resulting oscillating one is:

enter image description here

HTH!

Edit 2

This is what you can expect from a hi-pass filter as described above, adding an exponential damping, instead of just disposing the low frequency components.

Program in Mathematica (just in case):

centerOsc[x_] := 
  Module[{list, n, fp, coef, s}, 
   list = (Transpose@FinancialData[#, "Jan. 1, 2005"])[[2]] &@x;
   n = Length@list;
   fp = Transpose[{N[Range[n]]/n, list}];
   coef = FourierDST[list, 1]/Sqrt[n/2];
   coef = Table[N[coef[[i]] (1 - E^(-i/6))], {i, 1, Length@coef}];
   s = IntegerPart[Length@coef/100]; s = 1;
   {fp, {#, 
       Sum[coef[[r]]*Sin[Pi r #], {r, s, n - 1}]} & /@ (N[Range[n]]/
       n)}];
l = {"GE", "GOOG", "IBM", "MSFT"} ;(*Real prices from*)
GraphicsGrid@
 Partition[ListLinePlot[centerOsc[#],
     Axes -> False, Frame -> True, PlotLabel -> #,
     PlotRange -> {{0.1, .9}, Full}, 
     Epilog -> Line[{{0, 0}, {1, 0}}]] & /@ l, 2]

enter image description here

Edit 2

Based on your last update, it seems that what you want can be achieved easier. Just see what you get by dividing reducing linearly the y axis by 50% and 80% (using your data, extracted from your plot):

enter image description here

and compare with your plot:

enter image description here

故乡的云 2024-11-03 01:21:18

我建议您做的第一件事是将所有指标标准化为均值 0 和标准差 1。这至少会将所有指标集中在 0 附近。

http://en.wikipedia.org/wiki/Standard_score

-拉尔夫·温特斯

The first thing I suggest you do is too standardize all of the indicators to a mean of 0 and standard deviation of 1. This at least will center all of your indicators around 0.

http://en.wikipedia.org/wiki/Standard_score

-Ralph Winters

小梨窩很甜 2024-11-03 01:21:18

我在您的示例中标记了输入/输出信号的低频分量:
在此处输入图像描述
看起来确实像 @belisarius 所说的那样,你想要的是 - 只需对信号进行 FFT 并删除低频部分。也就是说 - 您需要高通滤波器算法。顺便说一句,高通滤波器也可以通过 1D 卷积 和高通来实现核心。例如,对于 3 分量内核向量,高通内核可以是 [-1; 3; -1]。在我看来,使用卷积实现高通滤波器是最简单的一种。但通常,就 CPU 使用率而言,通过 FFT 实现是最快的。

I've marked low frequency component of input/output signals in your example:
enter image description here
Seems really as @belisarius says what you want is - just do FFT on signal and remove low frequency parts. That is - you need high pass filter algorithm. BTW, high pass filter can be also implemented with 1D convolution and high-pass kernel. For example,- for 3 component kernel vector, high-pass kernel could be [-1; 3; -1]. In my opinion high-pass filter implementation with convolution is easiest one. But usually implementation through FFT is fastest one in relation to cpu usage.

hth

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文