Minitrader1337
Hej - en snabb översättning här - har ej testat dock - men du kan ju se hur funkar:
(se inställning L0, L1, L2, L3, globala dataserier)
// Laguerre RSI
local alpha = 0.2;
local LaRSI = 0;
// L0, L1, L2, L3 -> Global dataseries
local gamma = 1.0 - alpha;
// Laguerre-filter
L0[0] = (1 - gamma) * Close[0] + gamma * L0[-1];
L1[0] = -gamma * L0[0]+ L0[-1] + gamma * L1[-1];
L2[0] = -gamma * L1[0]+ L1[-1] + gamma * L2[-1];
L3[0] = -gamma * L2[0]+ L2[-1] + gamma * L3[-1];
// Uppgångar och nedgångar
local cu = 0;
if (L0[0] > L1[0]) cu = cu + (L0[0] - L1[0]);
if (L1[0] > L2[0]) cu = cu + (L1[0] - L2[0]);
if (L2[0] > L3[0]) cu = cu + (L2[0] - L3[0]);
local cd = 0;
if (L0[0] < L1[0]) cd = cd + (L1[0] - L0[0]);
if (L1[0] < L2[0]) cd = cd + (L2[0] - L1[0]);
if (L2[0] < L3[0]) cd = cd + (L3[0] - L2[0]);
// RSI-beräkning
if (cu + cd != 0)
LaRSI = cu / (cu + cd)
else
LaRSI = 0;
// Summering
plot1[0] = LaRSI * 100.0;
//plot2[0] = 20; // Lower Threshold
//plot2[0] = 80; // Upper Threshold