Calculating TenkanSen an KijunSen (Conversion line and Base line) in Ichimoku indicator using JavaScrpit

huangapple go评论79阅读模式
英文:

Calculating TenkanSen an KijunSen (Conversion line and Base line) in Ichimoku indicator using JavaScrpit

问题

我们有一组数据,每个周期都有数据,包括今天和之前的几天,数据包括开盘价、最低价、最高价和收盘价。
TenkanSen是通过将最近9个周期中的最高价加上最低价,然后除以2来计算的。而计算KijunSen所需的周期数为26。
信息历史记录的格式如下:[ih].[n].PriceMax表示最高价,其中n是天数(之前的天数),所以我们知道[ih].[0].PriceMax是昨天的最高价。最低价使用[ih].[n].PriceMin,并自行计算!
现在,对于TenkanSen,9个周期的最高价在[ih].[0].PriceMax到[ih].[8].PriceMax之间,而对于KijunSen,26个周期的最高价在[ih].[0].PriceMax到[ih].[25].PriceMax之间,我们如何计算TenkanSen和KijunSen?

我使用了以下代码:

var TenkanSenMin = ([ih][0].PriceMin+ [ih][1].PriceMin+ [ih][2].PriceMin+ [ih][3].PriceMin+ [ih][4].PriceMin+ [ih][5].PriceMin+ [ih][6].PriceMin+ [ih][7].PriceMin+ [ih][8].PriceMin)/9

var TenkanSenMax = ([ih][0].PriceMax+ [ih][1].PriceMax+ [ih][2].PriceMax+ [ih][3].PriceMax+ [ih][4].PriceMax+ [ih][5].PriceMax+ [ih][6].PriceMax+ [ih][7].PriceMax+ [ih][8].PriceMax)/9

var TenkanSen = (TenkanSenMin + TenkanSenMax) / 2;

var KijunSenMin = ([ih][0].PriceMin+ [ih][1].PriceMin+ [ih][2].PriceMin+ [ih][3].PriceMin+ [ih][4].PriceMin+ [ih][5].PriceMin+ [ih][6].PriceMin+ [ih][7].PriceMin+ [ih][8].PriceMin+ [ih][9].PriceMin+ [ih][10].PriceMin+ [ih][11].PriceMin+ [ih][12].PriceMin+ [ih][13].PriceMin+ [ih][14].PriceMin+ [ih][15].PriceMin+ [ih][16].PriceMin+ [ih][17].PriceMin+ [ih][18].PriceMin+ [ih][19].PriceMin+ [ih][20].PriceMin+ [ih][21].PriceMin+ [ih][22].PriceMin+ [ih][23].PriceMin+ [ih][24].PriceMin+ [ih][25].PriceMin)/26

var KijunSenMax =([ih][0].PriceMax+ [ih][1].PriceMax+ [ih][2].PriceMax+ [ih][3].PriceMax+ [ih][4].PriceMax+ [ih][5].PriceMax+ [ih][6].PriceMax+ [ih][7].PriceMax+ [ih][8].PriceMax+ [ih][9].PriceMax+ [ih][10].PriceMax+ [ih][11].PriceMax+ [ih][12].PriceMax+ [ih][13].PriceMax+ [ih][14].PriceMax+ [ih][15].PriceMax+ [ih][16].PriceMax+ [ih][17].PriceMax+ ([ih][18].PriceMax)+ [ih][19].PriceMax+ [ih][20].PriceMax+ [ih][21].PriceMax+ [ih][22].PriceMax+ [ih][23].PriceMax+ [ih][24].PriceMax+ [ih][25].PriceMax)/26

var KijunSen = (KijunSenMin + KijunSenMax) / 2;
英文:

<p>We have set of data for each period (such as daily including today and days before) that consists of 4 data, open, lowest, highest and close.
TenkanSen is a number that is calculated by adding highest high between last 9 periods to their lower low divided by 2. and the number of periods to calculate for KijunSen is 26.</p>
The information history is in the following format: [ih].[n].PriceMax for highest price and n is the number of days (before) so we know that [ih].[0].PriceMax is the highest from yesterday. Lowest uses [ih].[n].PriceMin and do the math yourself!<p>
Now that the 9 periods high is between [ih].[0].PriceMax to [ih].[8].PriceMax for TenkanSen, and [ih].[0].PriceMax to [ih].[25].PriceMax for KijunSen, how can we calculate TenkanSen an KijunSen?</p>

I used this

var TenkanSenMin = ([ih][0].PriceMin+ [ih][1].PriceMin+ [ih][2].PriceMin+ [ih][3].PriceMin+ [ih][4].PriceMin+ [ih][5].PriceMin+ [ih][6].PriceMin+ [ih][7].PriceMin+ [ih][8].PriceMin)/9
var TenkanSenMax = ([ih][0].PriceMax+ [ih][1].PriceMax+ [ih][2].PriceMax+ [ih][3].PriceMax+ [ih][4].PriceMax+ [ih][5].PriceMax+ [ih][6].PriceMax+ [ih][7].PriceMax+ [ih][8].PriceMax)/9
var TenkanSen = (TenkanSenMin + TenkanSenMax) / 2;
var KijunSenMin = ([ih][0].PriceMin+ [ih][1].PriceMin+ [ih][2].PriceMin+ [ih][3].PriceMin+ [ih][4].PriceMin+ [ih][5].PriceMin+ [ih][6].PriceMin+ [ih][7].PriceMin+ [ih][8].PriceMin+ [ih][9].PriceMin+ [ih][10].PriceMin+ [ih][11].PriceMin+ [ih][12].PriceMin+ [ih][13].PriceMin+ [ih][14].PriceMin+ [ih][15].PriceMin+ [ih][16].PriceMin+ [ih][17].PriceMin+ [ih][18].PriceMin+ [ih][19].PriceMin+ [ih][20].PriceMin+ [ih][21].PriceMin+ [ih][22].PriceMin+ [ih][23].PriceMin+ [ih][24].PriceMin+ [ih][25].PriceMin)/26
var KijunSenMax =([ih][0].PriceMax+ [ih][1].PriceMax+ [ih][2].PriceMax+ [ih][3].PriceMax+ [ih][4].PriceMax+ [ih][5].PriceMax+ [ih][6].PriceMax+ [ih][7].PriceMax+ [ih][8].PriceMax+ [ih][9].PriceMax+ [ih][10].PriceMax+ [ih][11].PriceMax+ [ih][12].PriceMax+ [ih][13].PriceMax+ [ih][14].PriceMax+ [ih][15].PriceMax+ [ih][16].PriceMax+ [ih][17].PriceMax+ ([ih][18].PriceMax)+ [ih][19].PriceMax+ [ih][20].PriceMax+ [ih][21].PriceMax+ [ih][22].PriceMax+ [ih][23].PriceMax+ [ih][24].PriceMax+ [ih][25].PriceMax)/26
var KijunSen = (KijunSenMin + KijunSenMax) / 2;

答案1

得分: 0

使用这个简单的数学代码:

var TenkanSenMin = Math.min([ih][0].PriceMin, [ih][1].PriceMin, [ih][2].PriceMin, [ih][3].PriceMin, [ih][4].PriceMin, [ih][5].PriceMin, [ih][6].PriceMin, [ih][7].PriceMin, [ih][8].PriceMin)

var TenkanSenMax = Math.max([ih][0].PriceMax, [ih][1].PriceMax, [ih][2].PriceMax, [ih][3].PriceMax, [ih][4].PriceMax, [ih][5].PriceMax, [ih][6].PriceMax, [ih][7].PriceMax, [ih][8].PriceMax)

var TenkanSen = (TenkanSenMin + TenkanSenMax) / 2;

var KijunSenMin = Math.min([ih][0].PriceMin, [ih][1].PriceMin, [ih][2].PriceMin, [ih][3].PriceMin, [ih][4].PriceMin, [ih][5].PriceMin, [ih][6].PriceMin, [ih][7].PriceMin, [ih][8].PriceMin, [ih][9].PriceMin, [ih][10].PriceMin, [ih][11].PriceMin, [ih][12].PriceMin, [ih][13].PriceMin, [ih][14].PriceMin, [ih][15].PriceMin, [ih][16].PriceMin, [ih][17].PriceMin, [ih][18].PriceMin, [ih][19].PriceMin, [ih][20].PriceMin, [ih][21].PriceMin, [ih][22].PriceMin, [ih][23].PriceMin, [ih][24].PriceMin, [ih][25].PriceMin)

var KijunSenMax = Math.max([ih][0].PriceMax, [ih][1].PriceMax, [ih][2].PriceMax, [ih][3].PriceMax, [ih][4].PriceMax, [ih][5].PriceMax, [ih][6].PriceMax, [ih][7].PriceMax, [ih][8].PriceMax, [ih][9].PriceMax, [ih][10].PriceMax, [ih][11].PriceMax, [ih][12].PriceMax, [ih][13].PriceMax, [ih][14].PriceMax, [ih][15].PriceMax, [ih][16].PriceMax, [ih][17].PriceMax, ([ih][18].PriceMax), [ih][19].PriceMax, [ih][20].PriceMax, [ih][21].PriceMax, [ih][22].PriceMax, [ih][23].PriceMax, [ih][24].PriceMax, [ih][25].PriceMax)

var KijunSen = (KijunSenMin + KijunSenMax) / 2;
英文:

Use this simple math code:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

var TenkanSenMin = Math.min([ih][0].PriceMin, [ih][1].PriceMin, [ih][2].PriceMin, [ih][3].PriceMin, [ih][4].PriceMin, [ih][5].PriceMin, [ih][6].PriceMin, [ih][7].PriceMin, [ih][8].PriceMin)
var TenkanSenMax = Math.max([ih][0].PriceMax, [ih][1].PriceMax, [ih][2].PriceMax, [ih][3].PriceMax, [ih][4].PriceMax, [ih][5].PriceMax, [ih][6].PriceMax, [ih][7].PriceMax, [ih][8].PriceMax)
var TenkanSen = (TenkanSenMin + TenkanSenMax) / 2;
var KijunSenMin = Math.min([ih][0].PriceMin, [ih][1].PriceMin, [ih][2].PriceMin, [ih][3].PriceMin, [ih][4].PriceMin, [ih][5].PriceMin, [ih][6].PriceMin, [ih][7].PriceMin, [ih][8].PriceMin, [ih][9].PriceMin, [ih][10].PriceMin, [ih][11].PriceMin, [ih][12].PriceMin, [ih][13].PriceMin, [ih][14].PriceMin, [ih][15].PriceMin, [ih][16].PriceMin, [ih][17].PriceMin, [ih][18].PriceMin, [ih][19].PriceMin, [ih][20].PriceMin, [ih][21].PriceMin, [ih][22].PriceMin, [ih][23].PriceMin, [ih][24].PriceMin, [ih][25].PriceMin)
var KijunSenMax = Math.max([ih][0].PriceMax, [ih][1].PriceMax, [ih][2].PriceMax, [ih][3].PriceMax, [ih][4].PriceMax, [ih][5].PriceMax, [ih][6].PriceMax, [ih][7].PriceMax, [ih][8].PriceMax, [ih][9].PriceMax, [ih][10].PriceMax, [ih][11].PriceMax, [ih][12].PriceMax, [ih][13].PriceMax, [ih][14].PriceMax, [ih][15].PriceMax, [ih][16].PriceMax, [ih][17].PriceMax, ([ih][18].PriceMax), [ih][19].PriceMax, [ih][20].PriceMax, [ih][21].PriceMax, [ih][22].PriceMax, [ih][23].PriceMax, [ih][24].PriceMax, [ih][25].PriceMax)
var KijunSen = (KijunSenMin + KijunSenMax) / 2;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年7月27日 17:51:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76778530.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定