2
Suivre
0
Abonnés

S'il vous plaît, guidez-moi sur la bonne façon d'écrire « calculer les prix les plus élevés et les plus bas dans la fourchette historique », merci.

Créé le: 2022-10-17 00:13:14, Mis à jour le: 2022-10-17 15:28:07
comments   5
hits   962

Merci de m’aider à écrire correctement le prix le plus élevé et le prix le plus bas de la période historique.

indicator("计算历史区间最高价、最低价", overlay=true)
//目的:想在开单时,找出开单前(输入历史长度)的最高价,或最低价,用于计算开单止损价。

varip ishistory_high_Price0 = array.new_float(0)                   //定义变量,初始化历史高价格为空的数组
varip ishistory_low_Price0 = array.new_float(0)                    //定义变量,初始化历史低价格为空的数组
var ishistory_length = input.int(15, minval=1, maxval=100, step=1) //定义变量,历史长度,输入为15,最小值1,最大值100,步长1
var ishistory_high_Price = na
var ishistory_low_Price  = na

if barstate.ishistory                                              //对历史K线执行计算(not barstate.ishistory当在实时abr时在执行)
    array.push(ishistory_high_Price0, nz(high[1], open))           //写入数组(变量ishistory_high_Price0的历史最高价元素,空值用开盘价)

    if array.size(ishistory_high_Price0) > ishistory_length        //当数组的长度大于变量长度的时候
        array.shift(ishistory_high_Price0)                         //删除数组(ishistory_high_Price0的第一个元素)
    [ishistory_high_Price0]

if barstate.ishistory                                              //对历史K线执行计算
    array.push(ishistory_low_Price0, nz(low[1], open))             //写入数组(变量ishistory_low_Price0的历史最低价元素,空值用开盘价)

    if array.size(ishistory_low_Price0) > ishistory_length         //当数组的长度大于变量长度的时候
        array.shift(ishistory_low_Price0)                          //删除数组(ishistory_low_Price0的第一个元素)
    [ishistory_low_Price0]

//需对历史高价格、历史低价格作出比较,并返回最大值(输入周期内的历史最高价、历史最低价)

//下面这个写法不正确!!!

ishistory_high_Price = array.max(ishistory_high_Price0, nz(high[1], open), ishistory_length)
ishistory_low_Price = array.min(ishistory_low_Price0, nz(low[1], open),ishistory_length)


plot(title = "数组ishistory_high_Price中的历史高价格:", ishistory_high_Price, color = color.blue)
plot(title = "数组ishistory_low_Price中的历史低价格:", ishistory_low_Price, color = color.red)

Bien que vous ayez appris le tutoriel d’introduction au langage PINE, la somme d’un tableau ou l’élément d’un tableau plus petit peut être adapté, mais il n’est pas possible de le réécrire pour une ligne K historique ! S’il vous plaît, aidez-nous à définir les variables, à comparer avec les prix historiquement élevés et les prix historiquement bas, à trouver les prix historiquement élevés et les prix historiquement bas.