数组求值
C# 新手,在 ninjatrader 中编程,我需要开发一个简单的函数来执行以下操作:
- 我需要检查股票高价是否高于之前的价格,通常这将通过索引来完成。如High[0]>高[1](因为零是当前价格)。
- 如果当前价格高于需要设置为索引变量(我猜测是数组),就好像 High[0] > 一样High[1] 则变量 = High[0]。
- 下一个评估以及我陷入困境的是如何评估当前最高价格是否大于数组中的每个元素。意味着价格在上涨。
一旦价格不再增加,函数的输出将需要是数组中最高价格的最高值。
感谢任何可以提供帮助的人!
本
Newbie to C#, programming in ninjatrader and i need to develop a simple function that performs the following:
- I need to check to see if a stocks high price is higher than the price before, generally this would be done with indexing. Such as High[0] > High[1] (as the zero being the current price).
- If the current price is higher than that needs to be set to a indexed variable (array i am guessing) as if High[0] > High[1] then variable = High[0].
- The next evaluation and where i am stuck is how do i evaluate if the current high price is greater than each element in the array. Meaning the price is increasing.
Once the price is no longer increasing the output of the function would need to be the Highest of the high prices in the array.
Thanks to anyone that can help!
Ben
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
3)
4)
但这两个选项都使用 LINQ。如果这不是一个选项,只需使用 for/foreach 循环。
3)
4)
But both options use LINQ. If that's not an option, just use a for/foreach loop.
我认为您的描述不完整或不正确,但目前您只是要求数组中的最高(最大值)值。
一个简单的解决方案:
I think your description is incomplete or incorrect, but currently you're just asking for the Higest (Max) value in an array.
A simple solution :
执行 foreach 循环并检查每个项目的值是否低于当前值
Do a foreach loop and check if each item's value is lower than your current value