- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在编写一个小型技术分析库,其中包含 TA-lib 中不可用的项目。我从在 cTrader 上找到的示例开始并将其与 TradingView 版本中的代码进行匹配。
这是来自 TradingView 的 Pine Script 代码:
len = input(9, minval=1, title="Length")
high_ = highest(hl2, len)
low_ = lowest(hl2, len)
round_(val) => val > .99 ? .999 : val < -.99 ? -.999 : val
value = 0.0
value := round_(.66 * ((hl2 - low_) / max(high_ - low_, .001) - .5) + .67 * nz(value[1]))
fish1 = 0.0
fish1 := .5 * log((1 + value) / max(1 - value, .001)) + .5 * nz(fish1[1])
fish2 = fish1[1]
这是我尝试实现该指标:
public class FisherTransform : IndicatorBase
{
public int Length = 9;
public decimal[] Fish { get; set; }
public decimal[] Trigger { get; set; }
decimal _maxHigh;
decimal _minLow;
private decimal _value1;
private decimal _lastValue1;
public FisherTransform(IEnumerable<Candle> candles, int length)
: base(candles)
{
Length = length;
RequiredCount = Length;
_lastValue1 = 1;
}
protected override void Initialize()
{
Fish = new decimal[Series.Length];
Trigger = new decimal[Series.Length];
}
public override void Compute(int startIndex = 0, int? endIndex = null)
{
if (endIndex == null)
endIndex = Series.Length;
for (int index = 0; index < endIndex; index++)
{
if (index == 1)
{
Fish[index - 1] = 1;
}
_minLow = Series.Average.Lowest(Length, index);
_maxHigh = Series.Average.Highest(Length, index);
_value1 = Maths.Normalize(0.66m * ((Maths.Divide(Series.Average[index] - _minLow, Math.Max(_maxHigh - _minLow, 0.001m)) - 0.5m) + 0.67m * _lastValue1));
_lastValue1 = _value1;
Fish[index] = 0.5m * Maths.Log(Maths.Divide(1 + _value1, Math.Max(1 - _value1, .001m))) + 0.5m * Fish[index - 1];
Trigger[index] = Fish[index - 1];
}
}
}
IndicatorBase class and CandleSeries class
问题
输出值似乎在预期范围内,但我的 Fisher 变换交叉不与我在 TradingView 版本的指标上看到的相匹配。
问题
如何在 C# 中正确实现 Fisher 变换指标?我希望它能匹配 TradingView 的 Fisher 变换输出。
我所知道的
我已经根据我个人编写的其他指标和来自 TA-Lib 的指标检查了我的数据,并且这些指标通过了我的单元测试。我还逐个蜡烛检查了我的数据与 TradingView 数据蜡烛,发现我的数据符合预期。所以我不怀疑我的数据是问题所在。
下图是应用于 TradingView 图表的上图 Fisher 转换代码。我的目标是尽可能匹配此输出。
费舍尔 青色触发器 洋红色
预期产出:
交叉于美国东部时间 15:30 完成
Fisher 值大约为 2.86
触发值约为 1.79
交叉于美国东部时间 10:45 完成
Fisher 值大约为 -3.67
大约触发值为 -3.10
我的实际输出:
交叉于美国东部时间 15:30 完成
我的 Fisher 值为 1.64
我的触发值是 1.99
交叉于美国东部时间 10:45 完成
我的 Fisher 值为 -1.63
我的触发值为 -2.00
To make your life easier I'm including a small console applicationcomplete with passing and failing unit tests. All unit tests areconducted against the same data set. The passing unit tests are from atested working Simple Moving Average indicator. The failing unittests are against the Fisher Transform indicator in question.
Project Files (5 月 14 日更新)
帮助我的 FisherTransform 测试通过,我将奖励赏金。
如果您需要任何其他资源或信息,请发表评论。
我会考虑的备选答案
用 C# 提交您自己的工作 FisherTransform
解释为什么我的 FisherTransform 实际上按预期工作
最佳答案
代码有两个错误。
1) 错误的额外括号。正确的行是:
_value1 = Maths.Normalize(0.66m * (Maths.Divide(Series.Average[index] - _minLow, Math.Max(_maxHigh - _minLow, 0.001m)) - 0.5m) + 0.67m * _lastValue1);
2) 最小和最大函数必须是:
public static decimal Highest(this decimal[] series, int length, int index)
{
var maxVal = series[index]; // <----- HERE WAS AN ERROR!
var lookback = Math.Max(index - length, 0);
for (int i = index; i-- > lookback;)
maxVal = Math.Max(series[i], maxVal);
return maxVal;
}
public static decimal Lowest(this decimal[] series, int length, int index)
{
var minVal = series[index]; // <----- HERE WAS AN ERROR!
var lookback = Math.Max(index - length, 0);
for (int i = index; i-- > lookback;)
{
//if (series[i] != 0) // <----- HERE WAS AN ERROR!
minVal = Math.Min(series[i], minVal);
}
return minVal;
}
3) 混淆测试参数。请重新检查您的单元测试值。更新测试后仍未修复。例如,第一个 FisherTransforms_ValuesAreReasonablyClose_First()
具有混合值
var fish = result.Fish.Last(); //is equal to -3.1113144510775780365063063706
var trig = result.Trigger.Last(); //is equal to -3.6057793808025449204415435710
// TradingView Values for NFLX 5m chart at 10:45 ET
var fisherValue = -3.67m;
var triggerValue = -3.10m;
关于c# - 如何正确计算 Fisher 变换指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56095306/
我在 Azure 中找不到几个 SQL 指标。任何人都可以帮助如何设置以下主题的指标。 1)产能利用率不足 2)池外的数据库数量 3)扩大规模 4)连接超时 提前致谢。 最佳答案 实际上,这些并不是
我要监控的应用程序提供了一个用于健康检查的 api 端点,它以 json 格式响应指标。例如: $ curl https://example.com/api/stats {"status":"suc
我正在考虑用于分析软件开发工作的软件指标。当我考虑在面向对象的软件中使用类似功能点的指标时,我遇到了一个有趣的挑战/问题。 考虑一个业务规则引擎。它是一种应用程序,由运行业务规则所需的组件组成,然后将
我要监控的应用程序提供了一个用于健康检查的 api 端点,它以 json 格式响应指标。例如: $ curl https://example.com/api/stats {"status":"suc
因此,我正在将旧的数据可视化转换为新平台,但我对他们的社区排序功能有点困惑。在原始代码中,作者似乎使用了带有余弦相似度计算器的凝聚聚类。我认为在 Javascript 中解决这个问题的最佳方法是使用
我不是专业程序员,但我正在尝试改变一些技术指标在名为 TradeStation 的金融图表包中的显示方式(与特定图表供应商无关)。 这就是问题所在:大多数指标都是围绕零点绘制的,有时它们会靠近零点摆动
我们存储了大量来 self 们服务的指标(大约 8000 万个事件)。我们必须根据数据生成报告。 我的问题比较笼统,哪些工具可以满足您的指标/报告需求?有什么推荐的吗? 我们使用 Apache 编写日
我们网站上的页面的 CLS 一直接近于零。这是有道理的,因为它们是服务器呈现的 HTML 页面,具有简单的静态布局。 最近我们添加了 content-visibility: auto 的使用,如下所示
我能想到几种方法来转这种类型的矩阵(数据框): dat = data.frame( x1 = rep(c('a', 'b'), 100), x2 = rep(c('x', 'y
我正在使用 codahale 指标(现在是 dropwizard 指标)来监控我系统中发生的一些“事件”。我正在使用 counters跟踪“事件”发生次数的指标。 我检查了记者为我的计数器指标打印的值
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 11 个月前关闭。 Improve this que
在不使用 Heapster 的情况下,有没有办法收集有关 Kubernetes 集群中节点的 CPU 或磁盘指标? Heapster 最初是如何收集这些指标的? 最佳答案 Kubernetes 监控在
对于二元分类问题,我有一个略微不平衡的数据集,正负比为 0.6。 我最近从这个答案中了解到了 auc 指标:https://stats.stackexchange.com/a/132832/12822
为了做一些参数调整,我喜欢用 Keras 循环一些训练函数。但是,我意识到在使用 tensorflow.keras.metrics.AUC() 时作为度量,对于每个训练循环,都会将一个整数添加到 au
我使用 Azure,现在我想在特定情况下添加短信通知。 当我使用基于日志的指标时,它效果很好,但我想针对特定异常创建通知。 下一个流程:抛出异常 => Azure 知道识别它 => Azure 发送有
我正在尝试访问给定cloudService的指标 我有以下代码: var metricsClient = new MetricsClient(new CertificateCloudCredentia
我正在尝试使用 R 和 xgboost 来研究我的模型。训练模型总体上效果很好,但对于插入符来说,度量存在一些问题。 我尝试为类列设置一个因子,但仍然没有结果。 我的数据 ID var1var2TA
我对编程还很陌生,有时它会用非常基本的概念来困扰我。我在我的 tableviewcontroller 中定义了一个 Activity 指示器作为 Outlet。 @IBOutlet weak var
我正在训练一个进行序列预测的模型。例如,给定某人之前写过的 10 个单词,我正在训练 LSTM 来预测他们将写的下一个单词。我有一个有时可以工作的模型,因此我想创建一个指标来跟踪模型通过词性标签预测下
我正在尝试使用 hystrix 来监控某个网络调用。但我尝试监控的所有指标始终为空。我做错了什么? 我通过实现一个(某种程度上)RESTful 接口(interface)来模拟网络调用,该接口(int
我是一名优秀的程序员,十分优秀!