如何在 Pine 脚本中获取以前的蜡烛

时间:2021-01-28 08:16:33

标签: pine-script

自从它购买以来,我正在尝试获得蜡烛的数量。

我是说

if ( something_happens ) 
    strategy.entry("buy", strategy.long)

How could I get this?
candles_since_entry = barssince(bought)

1 个答案:

答案 0 :(得分:0)

//@version=4
study("My Script")

var bool    something_happens = true
var int     bar_entry = na

if (something_happens)
    // strategy.entry("buy", strategy.long)
    bar_entry := bar_index
    
candles_since_entry = bar_index - bar_entry

plot(na)