convert to PowerLanguage

Questions about MultiCharts and user contributed studies.
Peverell7
Posts: 3
Joined: 18 May 2023

convert to PowerLanguage

Postby Peverell7 » 18 May 2023

hello everyone, can anyone convert this code to PowerLanguage? https://it.tradingview.com/script/Y8v4W ... t-LuxAlgo/

i think is Pine Script.

Peverell7
Posts: 3
Joined: 18 May 2023

Re: convert to PowerLanguage

Postby Peverell7 » 23 May 2023

up

Peverell7
Posts: 3
Joined: 18 May 2023

Re: convert to PowerLanguage

Postby Peverell7 » 31 May 2023

up

HellGhostEvocatorX
Posts: 77
Joined: 10 Feb 2022
Has thanked: 46 times
Been thanked: 9 times

Re: convert to PowerLanguage

Postby HellGhostEvocatorX » 31 May 2023

i only use multicharts.net, so i cant test ist. but the following code is the answer from chatgpt:

Code: Select all

Inputs: length(50), fcast(50), fmode("Similarity"), cmode("Cumulative"), fcast_col(ColorRGB(33, 87, 243)), fcast_style("· · ·"), show_area(True), fcast_area(ColorRGB(255, 93, 0, 50)), corr_area(ColorRGB(12, 181, 26, 50)), eval_area(ColorRGB(128, 128, 128, 50)); Vars: lines[200], n(0), d(0), top(0), btm(0), val(0), k(0), A[200], X[200], a(0), b(0), r(0), prev(0), current(0), e(0), l(0), x(0), alpha(0), beta(0); if BarIndex = 1 then begin for var i = 0 to fcast - 1 do lines[i] = TL_New(0, 0, 0, 0); end; n = BarIndex; d = Close - Close[1]; top = Highest(Close, length + fcast * 2); btm = Lowest(Close, length + fcast * 2); if LastBar then begin val = 0; k = 0; A[0] = 0; X[0] = 0; for var i = 0 to fcast * 2 + length do begin A[i] = Close[i]; if cmode = "Linreg" then X[i] = i; end; a = A[0] .. A[fcast - 1]; for var i = 0 to length - 1 do begin b = A[fcast + i] .. A[fcast * 2 + i - 1]; r = Covariance(a, b) / (Stdev(a) * Stdev(b)); if fmode = "Similarity" then val = if r >= val[1] then r else val[1] else val = if r <= val[1] then r else val[1]; k = if val = r then i else k; end; prev = Close; current = Close; for var i = 0 to fcast - 1 do begin e = d[fcast + k + (fcast - i - 1)]; if cmode = "Mean" then current = Average(a) + e else if cmode = "Linreg" then begin a = A[0] .. A[fcast]; x = X[0] .. X[fcast]; alpha = Covariance(a, x) / Variance(x); beta = Average(a) - alpha * Average(x); current = alpha * (n + i + 1) + beta + e; end else current = current + e; l = lines[i]; TL_SetBeginEnd(l, n + i, prev, n + i + 1, current); TL_SetColor(l, fcast_col); if fcast_style = "- - -" then TL_SetStyle(l, TL_DASHED) else if fcast_style = "· · ·" then TL_SetStyle(l, TL_DOTTED); prev = current; end; if show_area then begin TL_DeleteObject(TL_NewRectangle(n - length - fcast * 2 + 1, top, n - fcast + 1, btm, 0, eval_area)); TL_DeleteObject(TL_NewRectangle(n - fcast + 1, top, n, btm, 0, fcast_area)); TL_DeleteObject(TL_NewRectangle(n - k - fcast * 2 + 1, btm, n - k - fcast, top, 0, corr_area)); end; end;


Return to “MultiCharts”