The below script is working fine and is generating signals, but not able to convert this into strategy and generate signals
study("Trend Magic", shorttitle="TM", overlay=true)
CCI = 20
ATR = 5
Multiplier=1
original=true
upSign = '↑' // indicates the indicator shows uptrend
downSign = '↓' // indicates the indicator showing downtrend
colorBuy= #2DFF03 // Good sign for long trade
colorSell = #733629 // Good sign for short trade
thisCCI = cci(close, CCI)
lastCCI = nz(thisCCI[1])
bufferDn= high + Multiplier * sma(tr,ATR)
bufferUp= low - Multiplier * sma(tr,ATR)
if (thisCCI >= 0 and lastCCI < 0)
bufferUp := bufferDn[1]
if (thisCCI <= 0 and lastCCI > 0)
bufferDn := bufferUp[1]
if (thisCCI >= 0)
if (bufferUp < bufferUp[1])
bufferUp := bufferUp[1]
else
if (thisCCI <= 0)
if (bufferDn > bufferDn[1])
bufferDn := bufferDn[1]
x=thisCCI >= 0 ?bufferUp:thisCCI <= 0 ?bufferDn:x[1]
swap=x>x[1]?1:x<x[1]?-1:swap[1]
swap2=swap==1?lime:red
swap3=thisCCI >=0 ?lime:red
swap4=original?swap3:swap2
bullTrendMagic = swap4 == lime and swap4[1] == red
bearTrendMagic = swap4 == red and swap4[1] == lime
plotchar(bullTrendMagic, title="TM", char=upSign, location=location.belowbar, color=colorBuy, transp=0, text="TM", textcolor=colorBuy, size=size.auto)
plotchar(bearTrendMagic, title="TM", char=downSign, location=location.abovebar, color=colorSell, transp=0, text="TM", textcolor=colorSell, size=size.auto)
The script is working fine and is generating signals, but not able to convert this into strategy and generate signals
Here is the information https://www.tradingview.com/pine-script-docs/en/v5/search.html?q=convert that you need to know to convert from v1 to v3, and after that using autoconvert feature to convert it from v3 to v4 and then to the v5.
Here is the information what strategy is. https://www.tradingview.com/pine-script-docs/en/v5/concepts/Strategies.html
The conversion to strategy means that you pass your
signalvariables intostrategy.entry()function.