简体   繁体   中英

How to find close based on condition in pinescript?

My query is how to find the Close of particular day (on Daily Timeframe) when my conditions met ? Like in my code when my condition met the Candle turned to color Purple, Now I want to find the Close of the previous day when this candle turned its color on 1H timeframe, I used security function but not getting the exact day's close by code, please help.

study(title="HIGH VOLATILE x 1",overlay=true,precision=2)
length = 10
str = sum(tr,length)
ltl = lowest(low <= close[1] ? low : close[1],length)
hth = highest(high >= close[1] ? high : close[1],length)
height = hth - ltl
chop = 100 * (log10(str / height) / log10(length))
choppedup = crossover(chop,61.8)
barcolor (choppedup ? purple : na) // **HERE MY STRATEGY GIVES ME THE PURPLE CANDLES WHEN CONDITIONS MET**


//END OF CHOP

a = barstate.isrealtime ? 1 : 0
oldprice=security(tickerid,'D',close[a]lookahead=barmerge.lookahead_off) **I WANT THIS CODE TO MODIFIED TO GET THE DATA OF CLOSING CANDLE A DAY BEFORE THE PURPLE CANDLE APPEARS**
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © adolgov

study(title="HIGH VOLATILE x 1", overlay=true, precision=2)
length = 10
str = sum(tr, length)
ltl = lowest(low <= close[1] ? low : close[1], length)
hth = highest(high >= close[1] ? high : close[1], length)
height = hth - ltl
chop = 100 * (log10(str / height) / log10(length))
choppedup = crossover(chop, 61.8)
barcolor(choppedup ? color.purple : na)  // **HERE MY STRATEGY GIVES ME THE PURPLE CANDLES WHEN CONDITIONS MET**


//END OF CHOP

oldprice = security(syminfo.tickerid, 'D', close[1], lookahead=barmerge.lookahead_on)  // **I WANT THIS CODE TO MODIFIED TO GET THE DATA OF CLOSING CANDLE A DAY BEFORE THE PURPLE CANDLE APPEARS**
plot(choppedup ? oldprice : na, style = plot.style_linebr)

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