The resource loading... loading...

Please show me how to write the indicator.

Author: thirty-six, Created: 2022-02-14 17:27:11, Updated:

If you want to write some specific indicator curve, let's say the EMA indicator, the cycle is set to 100, but I want the price to be the highest price or the lowest price on the k-line, respectively.


More

Inventors quantify - small dreamsFor example, the highest price: 1, get the K-line data. 2 traversing the K-line data and forming an array of the highest price of each BAR. 3, Calculated with a well-constructed maximum-price array passing indicator function.

thirty-sixThank you, big brother. The problem is solved.

Inventors quantify - small dreamsThis is an iterative algorithm, which is the EMA value corresponding to the previous BAR.

thirty-sixBig Brother The known formula for calculating EMA is EMA ((n) =2/(n+1) x ((the highest price of this cycle - last cycle EMA ((n)) + last cycle EMA ((n)) So in the process of writing the above formula in the code, let's say the last cycle EMA (n) is written as

thirty-sixThank you.