简体   繁体   中英

pine script. merging 2 charts into one

I am searching for a pine-script that calculates an average-chart out of 2 given chart-symbols an after that shows me the MA200 of the newly generated chart. Does anybody has this? Or knows how to do? Best Regards

you can get the close price of both contracts using request.security. Then you can find average of two closes and plot it. Then you can find sma of avg and plot it.

Example:

//@version=5
indicator(title="Indicator Merge By Rohit",overlay=true)
symbol1 = input.symbol("CL1!","Symbol1")
symbol2 = input.symbol("UKOIL","Symbol2")
close1=request.security(symbol1, timeframe.period, close, barmerge.gaps_off)
close2=request.security(symbol2,timeframe.period, close, barmerge.gaps_off)
avg=(close1+close2)/2
plot(avg)
plot(ta.sma(avg,200))

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