0

I have been trying to convert Pinescript v5 code to EasyLanguage, but am not sure how. Can someone please help convert this for me?

I have used many resources I could find online and have tried manually doing this as well, but nothing seems to work.

The strategy mainly takes the triple exponential moving average along with quantitative qualitative estimation, and when both move positively that is when I buy, and when the qqe goes negative I sell

Here is the code:

//@version=5
strategy("qqe ma", overlay=true, margin_long=100, margin_short=100)

longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))

shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))


RSI_Period = input(6, title='RSI Length')
SF = input(5, title='RSI Smoothing')
QQE = input(3, title='Fast QQE Factor')
ThreshHold = input(3, title='Thresh-hold')

src = input(close, title='RSI Source')

Wilders_Period = RSI_Period * 2 - 1


Rsi = ta.rsi(src, RSI_Period)
RsiMa = ta.ema(Rsi, SF)
AtrRsi = math.abs(RsiMa[1] - RsiMa)
MaAtrRsi = ta.ema(AtrRsi, Wilders_Period)
dar = ta.ema(MaAtrRsi, Wilders_Period) * QQE

longband = 0.0
shortband = 0.0
trend = 0

DeltaFastAtrRsi = dar
RSIndex = RsiMa
newshortband = RSIndex + DeltaFastAtrRsi
newlongband = RSIndex - DeltaFastAtrRsi
longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ? math.max(longband[1], newlongband) : newlongband
shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ? math.min(shortband[1], newshortband) : newshortband
cross_1 = ta.cross(longband[1], RSIndex)
trend := ta.cross(RSIndex, shortband[1]) ? 1 : cross_1 ? -1 : nz(trend[1], 1)
FastAtrRsiTL = trend == 1 ? longband : shortband


length = input.int(50, minval=1, title='Bollinger Length')
mult = input.float(0.35, minval=0.001, maxval=5, step=0.1, title='BB Multiplier')
basis = ta.sma(FastAtrRsiTL - 50, length)
dev = mult * ta.stdev(FastAtrRsiTL - 50, length)
upper = basis + dev
lower = basis - dev
color_bar = RsiMa - 50 > upper ? #00c3ff : RsiMa - 50 < lower ? #ff0062 : color.gray


// Zero cross
QQEzlong = 0
QQEzlong := nz(QQEzlong[1])
QQEzshort = 0
QQEzshort := nz(QQEzshort[1])
QQEzlong := RSIndex >= 50 ? QQEzlong + 1 : 0
QQEzshort := RSIndex < 50 ? QQEzshort + 1 : 0

Zero = hline(0, color=color.white, linestyle=hline.style_dotted, linewidth=1)


RSI_Period2 = input(6, title='RSI Length')
SF2 = input(5, title='RSI Smoothing')
QQE2 = input(1.61, title='Fast QQE2 Factor')
ThreshHold2 = input(3, title='Thresh-hold')

src2 = input(close, title='RSI Source')

Wilders_Period2 = RSI_Period2 * 2 - 1


Rsi2 = ta.rsi(src2, RSI_Period2)
RsiMa2 = ta.ema(Rsi2, SF2)
AtrRsi2 = math.abs(RsiMa2[1] - RsiMa2)
MaAtrRsi2 = ta.ema(AtrRsi2, Wilders_Period2)
dar2 = ta.ema(MaAtrRsi2, Wilders_Period2) * QQE2
longband2 = 0.0
shortband2 = 0.0
trend2 = 0

DeltaFastAtrRsi2 = dar2
RSIndex2 = RsiMa2
newshortband2 = RSIndex2 + DeltaFastAtrRsi2
newlongband2 = RSIndex2 - DeltaFastAtrRsi2
longband2 := RSIndex2[1] > longband2[1] and RSIndex2 > longband2[1] ? math.max(longband2[1], newlongband2) : newlongband2
shortband2 := RSIndex2[1] < shortband2[1] and RSIndex2 < shortband2[1] ? math.min(shortband2[1], newshortband2) : newshortband2
cross_2 = ta.cross(longband2[1], RSIndex2)
trend2 := ta.cross(RSIndex2, shortband2[1]) ? 1 : cross_2 ? -1 : nz(trend2[1], 1)
FastAtrRsi2TL = trend2 == 1 ? longband2 : shortband2





Greenbar1 = RsiMa2 - 50 > ThreshHold2
Greenbar2 = RsiMa - 50 > upper

Redbar1 = RsiMa2 - 50 < 0 - ThreshHold2
Redbar2 = RsiMa - 50 < lower




// === GENERAL INPUTS ===
UseCurrentI = input(true, 'Use Current Chart Resolution?')
TimeFrameI = input.timeframe(title='Use Different Timeframe? Uncheck Box Above', defval='D')

umaOpt1I = input(0.85, 'Optional Values 1 (alma offset)')
umaOpt2I = input(6.0, 'Optional Values 2 (alma sigma)')
umaVolumeI = input(false, 'Use Volume to Refine ?')
umaMainSrcI = input(close, 'UMA Main Source')
umaMainLenI = input(20, title='UMA Main Moving Average Length')
umaMainTypeI = input.int(1, minval=1, maxval=9, title='1=SMA, 2=EMA, 3=WMA, 4=TEMA, 5=RMA, 6=HullMA, 7=SWMA, 8=VWAP, 9=ALMA ')


// === SERIES SETUP ===
TimeFrame = UseCurrentI ? timeframe.period : TimeFrameI

uma(type, src, len, vol, opt1, opt2) =>
    // 1) Simple Moving Average (SMA)
    vwma_1 = ta.vwma(src, len)
    sma_1 = ta.sma(src, len)
    _1 = vol ? vwma_1 : sma_1
    // 2) Exponential Moving Average (EMA)
    ema_1 = ta.ema(src * volume, len)
    ema_2 = ta.ema(volume, len)
    ema_3 = ta.ema(src, len)
    _2 = vol ? ema_1 / ema_2 : ema_3
    // 3) Weighted moving average (WMA)
    wma_1 = ta.wma(src * volume, len)
    wma_2 = ta.wma(volume, len)
    wma_3 = ta.wma(src, len)
    _3 = vol ? wma_1 / wma_2 : wma_3
    // 4) Triple Exponential Moving Average
    ema_4 = ta.ema(src * volume, len)
    ema_5 = ta.ema(volume, len)
    ema_6 = ta.ema(src, len)
    ema1 = vol ? ema_4 / ema_5 : ema_6
    ema_7 = ta.ema(ema1 * volume, len)
    ema_8 = ta.ema(volume, len)
    ema_9 = ta.ema(ema1, len)
    ema2 = vol ? ema_7 / ema_8 : ema_9
    ema_10 = ta.ema(ema2 * volume, len)
    ema_11 = ta.ema(volume, len)
    ema_12 = ta.ema(ema2, len)
    ema3 = vol ? ema_10 / ema_11 : ema_12
    _4 = 3 * (ema1 - ema2) + ema3
    // 5) Moving average used in RSI (RMA)
    rma_1 = ta.rma(src * volume, len)
    rma_2 = ta.rma(volume, len)
    rma_3 = ta.rma(src, len)
    _5 = vol ? rma_1 / rma_2 : rma_3
    // 6) Hull moving average
    _6 = ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len)))
    // 7) Symmetrically weighted (triangular) moving average (SWMA)
    _7 = ta.swma(src)
    // 8) Volume-weighted average price (VWAP)
    _8 = ta.vwap(src)
    // 9) Arnaud Legoux Moving Average (ALMA)
    alma_1 = ta.alma(src * volume, len, opt1, opt2)
    alma_2 = ta.alma(volume, len, opt1, opt2)
    alma_3 = ta.alma(src, len, opt1, opt2)
    _9 = vol ? alma_1 / alma_2 : alma_3
    type == 1 ? _1 : type == 2 ? _2 : type == 3 ? _3 : type == 4 ? _4 : type == 5 ? _5 : type == 6 ? _6 : type == 7 ? _7 : type == 8 ? _8 : _9

umaMainMAChoice = uma(umaMainTypeI, umaMainSrcI, umaMainLenI, umaVolumeI, umaOpt1I, umaOpt2I)
umaMainMA = request.security(syminfo.tickerid, TimeFrame, umaMainMAChoice)
umaMainMAColor = request.security(syminfo.tickerid, TimeFrame, umaMainMA >= umaMainMA[1]) ? #04ff00 : #ff0000


if(umaMainMA >= umaMainMA[1] and (Greenbar1 and Greenbar2 == 1 ? RsiMa2 - 50 : na))
    strategy.entry("My Long Entry Id", strategy.long)
    if(FastAtrRsi2TL - 50  <= 0)
        strategy.close_all('closing long')
if(not(umaMainMA >= umaMainMA[1]) and (Redbar1 and Redbar2 == 1 ? RsiMa2 - 50 : na))
    strategy.entry("My Short Entry Id", strategy.short)
    if(FastAtrRsi2TL - 50  >= 0)
        strategy.close_all('closing short')
Adyanth
  • 1
  • 1
  • Pine Script looks correct, share the Easy Language code you tried and specify the lines where you got stuck. This is not a code-writing service. – e2e4 Feb 09 '23 at 12:32

0 Answers0