简体   繁体   中英

How to get the previous candles in Pine script

I am trying to get the qty of candles since it bought.

I mean

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

How could I get this?
candles_since_entry = barssince(bought)
//@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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM