hello,
i´m relatively new to efs and need some help. i found an indicator called TRIX. what i would like to have is an moving average of the trix plot in the same subgraph. basically it should look like stochastics where TRIX is plot 1 and the moving avgerage of plot 1 = plot 2. (cross up is a buy, cross down is a sell signal).
can anybody help me out please?
below is the code or you can find the file doing a search in 'file sharing' (search for TRIX).
TIA and best regards,
kev
---------------------------------------------------------------
function preMain()
{
setStudyTitle("Triple Exponential Average");
setCursorLabelName("TRIX", 0);
setCursorLabelName("Zero Line", 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
}
var XA1_1 = 0.0;
var XA2_1 = 0.0;
var XA3_1 = 0.0;
function main(sPrice,nLength)
{
var Price = "Close";
if (sPrice != null) Price = sPrice;
var len = 18;
if (nLength != null) len = nLength;
var vPrice = Math.log(getValue(Price, 0));
var Factor = 2 / (len + 1);
var XA1 = Factor * vPrice + (1 - Factor) * XA1_1;
var XA2 = Factor * XA1 + (1 - Factor) * XA2_1;
var XA3 = Factor * XA2 + (1 - Factor) * XA3_1;
var TripleXAvg = (XA3 - XA3_1) * 10000;
if (getBarState() == BARSTATE_NEWBAR)
{
XA1_1 = XA1;
XA2_1 = XA2;
XA3_1 = XA3;
}
return new Array(TripleXAvg, 0);
}
i´m relatively new to efs and need some help. i found an indicator called TRIX. what i would like to have is an moving average of the trix plot in the same subgraph. basically it should look like stochastics where TRIX is plot 1 and the moving avgerage of plot 1 = plot 2. (cross up is a buy, cross down is a sell signal).
can anybody help me out please?
below is the code or you can find the file doing a search in 'file sharing' (search for TRIX).
TIA and best regards,
kev
---------------------------------------------------------------
function preMain()
{
setStudyTitle("Triple Exponential Average");
setCursorLabelName("TRIX", 0);
setCursorLabelName("Zero Line", 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
}
var XA1_1 = 0.0;
var XA2_1 = 0.0;
var XA3_1 = 0.0;
function main(sPrice,nLength)
{
var Price = "Close";
if (sPrice != null) Price = sPrice;
var len = 18;
if (nLength != null) len = nLength;
var vPrice = Math.log(getValue(Price, 0));
var Factor = 2 / (len + 1);
var XA1 = Factor * vPrice + (1 - Factor) * XA1_1;
var XA2 = Factor * XA1 + (1 - Factor) * XA2_1;
var XA3 = Factor * XA2 + (1 - Factor) * XA3_1;
var TripleXAvg = (XA3 - XA3_1) * 10000;
if (getBarState() == BARSTATE_NEWBAR)
{
XA1_1 = XA1;
XA2_1 = XA2;
XA3_1 = XA3;
}
return new Array(TripleXAvg, 0);
}