I've utilised the RelativeStrengthRatio.efs on the Library to create a Relative Performance indicator. I've made the following changes to the code:
function main(Symbol1) {
if (vLoaded == false) {
cSym = getSymbol();
if (Symbol1 == null) {
vSym = "$STI-SES";
vEdit = false
} else {
vSym = Symbol1;
vEdit = true;
}
vLoaded = true;
preMain();
}
if (vSym != null) {
var StockChg = (close(0)/close(-1)-1)*100;
var CurrIndex = close(0, 1, vSym);
var PrevIndex = close(-1, 1, vSym);
var IndexChg = (CurrIndex/PrevIndex-1)*100;
var RelPerf = StockChg-IndexChg;
return RelPerf;
} else {
return;
}
}
The above works as I expect. However, what I want to do is to create a Cumulative Relative Performance which adds each period's Rel Performance. The code below which I wrote does not plot however:
if (vSym != null) {
var StockChg = (close(0)/close(-1)-1)*100;
var CurrIndex = close(0, 1, vSym);
var PrevIndex = close(-1, 1, vSym);
var IndexChg = (CurrIndex/PrevIndex-1)*100;
var RelPerf = StockChg-IndexChg;
if (getCurrentBarCount() > 1) {
var CumRelPerf = CumRelPerf(-1) + RelPerf(0);
} else {
CumRelPerf = 0;
}
return CumRelPerf;
} else {
return;
}
I think the problem has to do with setting the Relative Performance of initial Bar 1 as 0, and the code I use above may be incorrect.
Would appreciate help/suggestions from anyone. Thanks.
function main(Symbol1) {
if (vLoaded == false) {
cSym = getSymbol();
if (Symbol1 == null) {
vSym = "$STI-SES";
vEdit = false
} else {
vSym = Symbol1;
vEdit = true;
}
vLoaded = true;
preMain();
}
if (vSym != null) {
var StockChg = (close(0)/close(-1)-1)*100;
var CurrIndex = close(0, 1, vSym);
var PrevIndex = close(-1, 1, vSym);
var IndexChg = (CurrIndex/PrevIndex-1)*100;
var RelPerf = StockChg-IndexChg;
return RelPerf;
} else {
return;
}
}
The above works as I expect. However, what I want to do is to create a Cumulative Relative Performance which adds each period's Rel Performance. The code below which I wrote does not plot however:
if (vSym != null) {
var StockChg = (close(0)/close(-1)-1)*100;
var CurrIndex = close(0, 1, vSym);
var PrevIndex = close(-1, 1, vSym);
var IndexChg = (CurrIndex/PrevIndex-1)*100;
var RelPerf = StockChg-IndexChg;
if (getCurrentBarCount() > 1) {
var CumRelPerf = CumRelPerf(-1) + RelPerf(0);
} else {
CumRelPerf = 0;
}
return CumRelPerf;
} else {
return;
}
I think the problem has to do with setting the Relative Performance of initial Bar 1 as 0, and the code I use above may be incorrect.
Would appreciate help/suggestions from anyone. Thanks.
Comment