简体   繁体   中英

Unable to plot buy/sell trendline with cloud like screenshot for TradingView in Pine Script

在此处输入图像描述

I am trying to build a BUY/SELL Indicator for TradingView by EMA.

Conditions for BUY Signal: The 9 EMA LINE (Green) is above the 18 EMA LINE (Red)

Conditions for SELL Signal: The 9 EMA LINE (Green) is below the 18 EMA LINE (Red)

When the above conditions are met it should give the respective BUY or SELL signal.

But, I am not being able to plot buy/sell trendline with cloud for the correct BUY/SELL signal that meets all the conditions.

My codes:

   //@version=5 
indicator(title='EMA', overlay=true)

s9ema = ta.ema(close, 9) 
s18ema = ta.ema(close, 18)

longCond = ta.crossover(s9ema, s18ema) 
shortCond = ta.crossunder(s9ema, s18ema)

bgcolor(s9ema>s18ema?color.new(color.green,92):s9ema<s18ema?color.new(color.red,92):na)
barcolor(s9ema>s18ema?color.new(color.green,0):s9ema<s18ema?color.new(color.red,0):na)

plotshape(series=longCond, title='BUY', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.green, 0), text='BUY', size=size.small) 
plotshape(series=shortCond, title='SELL', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.red, 0), text='SELL', size=size.small)

Your image shows a supertrend while your source code seems to be about a two EMA cross strategy

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