V. Patel
V. Patel

Reputation: 3

Pinescript: Paint the price of crossover candle

I plan to take a long entry for a Crossover and wanted to find out

  1. how to paint the closing price of the crossover on the chart?

  2. Find out what would be the highest price of the last 10 candles when the crossover occurs?

Below function gives me the entry.

src = input(close, title="Source")
offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
out1 = ema(src, len1)
out2 = ema(src, len2)
out3 = ema(src, len3)
Long_TP1 = crossover(out1,out3)

Upvotes: 0

Views: 462

Answers (1)

AnyDozer
AnyDozer

Reputation: 2568

//@version=4
study(title="Help (Price Cross)", overlay=true)
len1 = input(defval=5,    title="Length 1")
len2 = input(defval=13,   title="Length 2")
len3 = input(defval=19,   title="Length 3")
src = input(close, title="Source")
offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)

out1 = ema(src, len1)
out2 = ema(src, len2)
out3 = ema(src, len3)
Long_TP1 = crossover(out1, out3)

var price_cr =0.0
var high10 = 0.0
hitemp = highest(high, 10)

if Long_TP1
    price_cr := close
    high10 := hitemp

plot(price_cr, color=color.blue)  
plot(high10, color=color.red) 

Upvotes: 0

Related Questions